|
@@ -9,7 +9,8 @@ import { |
|
@@ -9,7 +9,8 @@ import { |
9
|
routeMapSettingsSchema,
|
9
|
routeMapSettingsSchema,
|
10
|
markerClusteringSettingsSchema,
|
10
|
markerClusteringSettingsSchema,
|
11
|
markerClusteringSettingsSchemaLeaflet,
|
11
|
markerClusteringSettingsSchemaLeaflet,
|
12
|
- hereMapSettingsSchema
|
12
|
+ hereMapSettingsSchema,
|
|
|
13
|
+ mapProviderSchema
|
13
|
} from './schemes';
|
14
|
} from './schemes';
|
14
|
import { MapWidgetStaticInterface, MapWidgetInterface } from './map-widget.interface';
|
15
|
import { MapWidgetStaticInterface, MapWidgetInterface } from './map-widget.interface';
|
15
|
import { OpenStreetMap, TencentMap, GoogleMap, HEREMap, ImageMap } from './providers';
|
16
|
import { OpenStreetMap, TencentMap, GoogleMap, HEREMap, ImageMap } from './providers';
|
|
@@ -17,24 +18,29 @@ import { parseData, parseArray, parseFunction } from './maps-utils'; |
|
@@ -17,24 +18,29 @@ import { parseData, parseArray, parseFunction } from './maps-utils'; |
17
|
|
18
|
|
18
|
export let TbMapWidgetV2: MapWidgetStaticInterface;
|
19
|
export let TbMapWidgetV2: MapWidgetStaticInterface;
|
19
|
TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface {
|
20
|
TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface {
|
|
|
21
|
+
|
20
|
map: LeafletMap;
|
22
|
map: LeafletMap;
|
21
|
provider: MapProviders;
|
23
|
provider: MapProviders;
|
22
|
schema;
|
24
|
schema;
|
23
|
data;
|
25
|
data;
|
24
|
|
26
|
|
25
|
- constructor(mapProvider: MapProviders, private drawRoutes, ctx, $element) {
|
27
|
+ constructor(public mapProvider: MapProviders, private drawRoutes, ctx, $element) {
|
|
|
28
|
+ if (this.map) {
|
|
|
29
|
+ this.map.map.remove();
|
|
|
30
|
+ delete this.map;
|
|
|
31
|
+ }
|
|
|
32
|
+
|
26
|
this.data = ctx.data;
|
33
|
this.data = ctx.data;
|
27
|
if (!$element) {
|
34
|
if (!$element) {
|
28
|
$element = ctx.$container[0];
|
35
|
$element = ctx.$container[0];
|
29
|
}
|
36
|
}
|
30
|
- this.provider = mapProvider;
|
|
|
31
|
- let MapClass = providerSets[mapProvider]?.MapClass;
|
|
|
32
|
- let settings = this.initSettings(ctx?.settings);
|
37
|
+ let settings = this.initSettings(ctx.settings);
|
|
|
38
|
+
|
|
|
39
|
+ let MapClass = providerSets[this.provider]?.MapClass;
|
33
|
if (!MapClass) {
|
40
|
if (!MapClass) {
|
34
|
return;
|
41
|
return;
|
35
|
}
|
42
|
}
|
36
|
this.map = new MapClass($element, settings);
|
43
|
this.map = new MapClass($element, settings);
|
37
|
- this.schema = providerSets[mapProvider]?.schema;
|
|
|
38
|
}
|
44
|
}
|
39
|
|
45
|
|
40
|
onInit() {
|
46
|
onInit() {
|
|
@@ -42,6 +48,7 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
@@ -42,6 +48,7 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
42
|
|
48
|
|
43
|
initSettings(settings: any) {
|
49
|
initSettings(settings: any) {
|
44
|
const functionParams = ['data', 'dsData', 'dsIndex'];
|
50
|
const functionParams = ['data', 'dsData', 'dsIndex'];
|
|
|
51
|
+ this.provider = settings.provider ? settings.provider : this.mapProvider;
|
45
|
const customOptions = {
|
52
|
const customOptions = {
|
46
|
mapProvider: this.provider,
|
53
|
mapProvider: this.provider,
|
47
|
mapUrl: settings?.mapImageUrl,
|
54
|
mapUrl: settings?.mapImageUrl,
|
|
@@ -53,6 +60,7 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
@@ -53,6 +60,7 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
53
|
tooltipPattern: settings.tooltipPattern ||
|
60
|
tooltipPattern: settings.tooltipPattern ||
|
54
|
"<b>${entityName}</b><br/><br/><b>Latitude:</b> ${" + settings.latKeyName + ":7}<br/><b>Longitude:</b> ${" + settings.lngKeyName + ":7}",
|
61
|
"<b>${entityName}</b><br/><br/><b>Latitude:</b> ${" + settings.latKeyName + ":7}<br/><b>Longitude:</b> ${" + settings.lngKeyName + ":7}",
|
55
|
label: settings.label || "${entityName}",
|
62
|
label: settings.label || "${entityName}",
|
|
|
63
|
+ defaultCenterPosition: settings?.defaultCenterPosition?.split(',') || [0,0],
|
56
|
currentImage: (settings.useMarkerImage && settings.markerImage?.length) ? {
|
64
|
currentImage: (settings.useMarkerImage && settings.markerImage?.length) ? {
|
57
|
url: settings.markerImage,
|
65
|
url: settings.markerImage,
|
58
|
size: settings.markerImageSize || 34
|
66
|
size: settings.markerImageSize || 34
|
|
@@ -74,9 +82,6 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
@@ -74,9 +82,6 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
74
|
this.map.onResize();//not work
|
82
|
this.map.onResize();//not work
|
75
|
}
|
83
|
}
|
76
|
|
84
|
|
77
|
- getSettingsSchema(): Object {
|
|
|
78
|
- return this.schema;
|
|
|
79
|
- }
|
|
|
80
|
|
85
|
|
81
|
resize() {
|
86
|
resize() {
|
82
|
this.map?.invalidateSize();
|
87
|
this.map?.invalidateSize();
|
|
@@ -88,9 +93,20 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
@@ -88,9 +93,20 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
88
|
}
|
93
|
}
|
89
|
|
94
|
|
90
|
public static settingsSchema(mapProvider, drawRoutes): Object {
|
95
|
public static settingsSchema(mapProvider, drawRoutes): Object {
|
91
|
- const providerInfo = providerSets[mapProvider];
|
|
|
92
|
- let schema = providerInfo.schema;
|
|
|
93
|
- schema.groupInfoes = [];
|
96
|
+ //const providerInfo = providerSets[mapProvider];
|
|
|
97
|
+ let schema = initSchema();
|
|
|
98
|
+
|
|
|
99
|
+ function initSchema() {
|
|
|
100
|
+ return {
|
|
|
101
|
+ schema: {
|
|
|
102
|
+ type: "object",
|
|
|
103
|
+ properties: {},
|
|
|
104
|
+ required: []
|
|
|
105
|
+ },
|
|
|
106
|
+ form: [],
|
|
|
107
|
+ groupInfoes: []
|
|
|
108
|
+ };
|
|
|
109
|
+ }
|
94
|
|
110
|
|
95
|
function addGroupInfo(title: string) {
|
111
|
function addGroupInfo(title: string) {
|
96
|
schema.groupInfoes.push({
|
112
|
schema.groupInfoes.push({
|
|
@@ -99,42 +115,69 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
@@ -99,42 +115,69 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
99
|
});
|
115
|
});
|
100
|
}
|
116
|
}
|
101
|
|
117
|
|
102
|
- function mergeSchema(newSchema) {
|
118
|
+ function addToSchema(newSchema) {
|
103
|
Object.assign(schema.schema.properties, newSchema.schema.properties);
|
119
|
Object.assign(schema.schema.properties, newSchema.schema.properties);
|
104
|
schema.schema.required = schema.schema.required.concat(newSchema.schema.required);
|
120
|
schema.schema.required = schema.schema.required.concat(newSchema.schema.required);
|
105
|
schema.form.push(newSchema.form);//schema.form.concat(commonMapSettingsSchema.form);
|
121
|
schema.form.push(newSchema.form);//schema.form.concat(commonMapSettingsSchema.form);
|
106
|
}
|
122
|
}
|
107
|
|
123
|
|
108
|
- if (providerInfo.name)
|
|
|
109
|
- addGroupInfo(providerInfo.name + ' Map Settings');
|
|
|
110
|
- schema.form = [schema.form];
|
124
|
+ function mergeSchemes(schemes: any[]) {
|
|
|
125
|
+ return schemes.reduce((finalSchema, schema) => {
|
|
|
126
|
+ return {
|
|
|
127
|
+ schema: {
|
|
|
128
|
+ properties: {
|
|
|
129
|
+ ...finalSchema.schema.properties,
|
|
|
130
|
+ ...schema.schema.properties
|
|
|
131
|
+ },
|
|
|
132
|
+ required: [
|
|
|
133
|
+ ...finalSchema.schema.required,
|
|
|
134
|
+ ...schema.schema.required
|
|
|
135
|
+ ]
|
|
|
136
|
+ },
|
|
|
137
|
+ form: [
|
|
|
138
|
+ ...finalSchema.form,
|
|
|
139
|
+ ...schema.form
|
|
|
140
|
+ ]
|
|
|
141
|
+ }
|
|
|
142
|
+ }, initSchema());
|
|
|
143
|
+ }
|
111
|
|
144
|
|
112
|
- mergeSchema(commonMapSettingsSchema);
|
145
|
+ function addCondition(schema, condition: String) {
|
|
|
146
|
+ schema.form = schema.form.map(element => {
|
|
|
147
|
+ if (typeof element === 'string') {
|
|
|
148
|
+ return {
|
|
|
149
|
+ key: element,
|
|
|
150
|
+ condition: condition
|
|
|
151
|
+ }
|
|
|
152
|
+ }
|
|
|
153
|
+ if (typeof element == 'object') {
|
|
|
154
|
+ if (element.condition) {
|
|
|
155
|
+ element.condition += ' && ' + condition
|
|
|
156
|
+ }
|
|
|
157
|
+ else element.condition = condition;
|
|
|
158
|
+ }
|
|
|
159
|
+ return element;
|
|
|
160
|
+ });
|
|
|
161
|
+ return schema;
|
|
|
162
|
+ }
|
|
|
163
|
+
|
|
|
164
|
+ addToSchema(mergeSchemes([mapProviderSchema,
|
|
|
165
|
+ ...Object.values(providerSets)?.map(
|
|
|
166
|
+ setting => addCondition(setting?.schema, `model.provider === '${setting.name}'`))]));
|
|
|
167
|
+
|
|
|
168
|
+ addGroupInfo("Map Provider Settings");
|
|
|
169
|
+ addToSchema(commonMapSettingsSchema);
|
113
|
addGroupInfo("Common Map Settings");
|
170
|
addGroupInfo("Common Map Settings");
|
114
|
|
171
|
|
115
|
if (drawRoutes) {
|
172
|
if (drawRoutes) {
|
116
|
- mergeSchema(routeMapSettingsSchema);
|
173
|
+ addToSchema(routeMapSettingsSchema);
|
117
|
addGroupInfo("Route Map Settings");
|
174
|
addGroupInfo("Route Map Settings");
|
118
|
} else if (mapProvider !== 'image-map') {
|
175
|
} else if (mapProvider !== 'image-map') {
|
119
|
- let clusteringSchema: any = {
|
|
|
120
|
- schema: {
|
|
|
121
|
- properties: {
|
|
|
122
|
- ...markerClusteringSettingsSchemaLeaflet.schema.properties,
|
|
|
123
|
- ...markerClusteringSettingsSchema.schema.properties
|
|
|
124
|
- },
|
|
|
125
|
- required: {
|
|
|
126
|
- ...markerClusteringSettingsSchemaLeaflet.schema.required,
|
|
|
127
|
- ...markerClusteringSettingsSchema.schema.required
|
|
|
128
|
- }
|
|
|
129
|
- },
|
|
|
130
|
- form: [
|
|
|
131
|
- ...markerClusteringSettingsSchemaLeaflet.form,
|
|
|
132
|
- ...markerClusteringSettingsSchema.form
|
|
|
133
|
- ]
|
|
|
134
|
- };
|
|
|
135
|
- mergeSchema(clusteringSchema);
|
176
|
+ let clusteringSchema = mergeSchemes([markerClusteringSettingsSchemaLeaflet, markerClusteringSettingsSchema])
|
|
|
177
|
+ addToSchema(clusteringSchema);
|
136
|
addGroupInfo("Markers Clustering Settings");
|
178
|
addGroupInfo("Markers Clustering Settings");
|
137
|
}
|
179
|
}
|
|
|
180
|
+ console.log(11, schema);
|
138
|
|
181
|
|
139
|
return schema;
|
182
|
return schema;
|
140
|
}
|
183
|
}
|
|
@@ -164,26 +207,27 @@ const providerSets = { |
|
@@ -164,26 +207,27 @@ const providerSets = { |
164
|
'openstreet-map': {
|
207
|
'openstreet-map': {
|
165
|
MapClass: OpenStreetMap,
|
208
|
MapClass: OpenStreetMap,
|
166
|
schema: openstreetMapSettingsSchema,
|
209
|
schema: openstreetMapSettingsSchema,
|
167
|
- name: "Openstreet"
|
210
|
+ name: "openstreet-map",
|
168
|
},
|
211
|
},
|
169
|
'tencent-map': {
|
212
|
'tencent-map': {
|
170
|
MapClass: TencentMap,
|
213
|
MapClass: TencentMap,
|
171
|
schema: tencentMapSettingsSchema,
|
214
|
schema: tencentMapSettingsSchema,
|
172
|
- name: "Tencent"
|
215
|
+ name: "tencent-map"
|
173
|
},
|
216
|
},
|
174
|
'google-map': {
|
217
|
'google-map': {
|
175
|
MapClass: GoogleMap,
|
218
|
MapClass: GoogleMap,
|
176
|
schema: googleMapSettingsSchema,
|
219
|
schema: googleMapSettingsSchema,
|
177
|
- name: "Openstreet"
|
220
|
+ name: "google-map"
|
178
|
},
|
221
|
},
|
179
|
'here': {
|
222
|
'here': {
|
180
|
MapClass: HEREMap,
|
223
|
MapClass: HEREMap,
|
181
|
schema: hereMapSettingsSchema,
|
224
|
schema: hereMapSettingsSchema,
|
182
|
- name: "HERE"
|
225
|
+ name: "here"
|
183
|
},
|
226
|
},
|
184
|
'image-map': {
|
227
|
'image-map': {
|
185
|
MapClass: ImageMap,
|
228
|
MapClass: ImageMap,
|
186
|
- schema: imageMapSettingsSchema
|
229
|
+ schema: imageMapSettingsSchema,
|
|
|
230
|
+ name: "image-map"
|
187
|
}
|
231
|
}
|
188
|
}
|
232
|
}
|
189
|
|
233
|
|
|
@@ -218,6 +262,5 @@ const defaultSettings = { |
|
@@ -218,6 +262,5 @@ const defaultSettings = { |
218
|
disableScrollZooming: false,
|
262
|
disableScrollZooming: false,
|
219
|
minZoomLevel: 16,
|
263
|
minZoomLevel: 16,
|
220
|
credentials: '',
|
264
|
credentials: '',
|
221
|
- defaultCenterPosition: [0, 0],
|
|
|
222
|
markerClusteringSetting: null,
|
265
|
markerClusteringSetting: null,
|
223
|
} |
266
|
} |