|
|
@ -4,19 +4,23 @@ import { deepClone } from '@core/utils'; |
|
|
import { openstreetMapSettingsSchema, googleMapSettingsSchema, imageMapSettingsSchema, tencentMapSettingsSchema, hereMapSettingsSchema, commonMapSettingsSchema, routeMapSettingsSchema, markerClusteringSettingsSchema, markerClusteringSettingsSchemaGoogle, markerClusteringSettingsSchemaLeaflet } from './schemes'; |
|
|
import { openstreetMapSettingsSchema, googleMapSettingsSchema, imageMapSettingsSchema, tencentMapSettingsSchema, hereMapSettingsSchema, commonMapSettingsSchema, routeMapSettingsSchema, markerClusteringSettingsSchema, markerClusteringSettingsSchemaGoogle, markerClusteringSettingsSchemaLeaflet } from './schemes'; |
|
|
import { MapWidgetStaticInterface, MapWidgetInterface } from './map-widget.interface'; |
|
|
import { MapWidgetStaticInterface, MapWidgetInterface } from './map-widget.interface'; |
|
|
import { OpenStreetMap, TencentMap, ImageMap, GoogleMap } from './providers'; |
|
|
import { OpenStreetMap, TencentMap, ImageMap, GoogleMap } from './providers'; |
|
|
|
|
|
import { string } from 'prop-types'; |
|
|
|
|
|
|
|
|
const providerSets = { |
|
|
const providerSets = { |
|
|
'openstreet-map': { |
|
|
'openstreet-map': { |
|
|
MapClass: OpenStreetMap, |
|
|
MapClass: OpenStreetMap, |
|
|
schema: openstreetMapSettingsSchema |
|
|
schema: openstreetMapSettingsSchema, |
|
|
|
|
|
name: "Openstreet" |
|
|
}, |
|
|
}, |
|
|
'tencent-map': { |
|
|
'tencent-map': { |
|
|
MapClass: TencentMap, |
|
|
MapClass: TencentMap, |
|
|
schema: tencentMapSettingsSchema |
|
|
schema: tencentMapSettingsSchema, |
|
|
|
|
|
name: "Tencent" |
|
|
}, |
|
|
}, |
|
|
'google-map': { |
|
|
'google-map': { |
|
|
MapClass: GoogleMap, |
|
|
MapClass: GoogleMap, |
|
|
schema: googleMapSettingsSchema |
|
|
schema: googleMapSettingsSchema, |
|
|
|
|
|
name: "Openstreet" |
|
|
}, |
|
|
}, |
|
|
'image-map': { |
|
|
'image-map': { |
|
|
MapClass: ImageMap, |
|
|
MapClass: ImageMap, |
|
|
@ -32,13 +36,12 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
|
|
|
|
|
|
|
constructor(mapProvider: MapProviders, drawRoutes, ctx, useDynamicLocations, $element, isEdit) { |
|
|
constructor(mapProvider: MapProviders, drawRoutes, ctx, useDynamicLocations, $element, isEdit) { |
|
|
console.log(ctx.settings); |
|
|
console.log(ctx.settings); |
|
|
|
|
|
|
|
|
// if(!$element) return
|
|
|
|
|
|
if (!$element) { |
|
|
if (!$element) { |
|
|
$element = ctx.$container[0]; |
|
|
$element = ctx.$container[0]; |
|
|
} |
|
|
} |
|
|
this.provider = mapProvider; |
|
|
this.provider = mapProvider; |
|
|
const options: MapOptions = { |
|
|
const baseOptions: MapOptions = { |
|
|
initCallback: () => { }, |
|
|
initCallback: () => { }, |
|
|
defaultZoomLevel: 8, |
|
|
defaultZoomLevel: 8, |
|
|
dontFitMapBounds: false, |
|
|
dontFitMapBounds: false, |
|
|
@ -51,11 +54,10 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
|
markerClusteringSetting: null |
|
|
markerClusteringSetting: null |
|
|
} |
|
|
} |
|
|
let MapClass = providerSets[mapProvider]?.MapClass; |
|
|
let MapClass = providerSets[mapProvider]?.MapClass; |
|
|
if(!MapClass){ |
|
|
if (!MapClass) { |
|
|
//delete this;
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
this.map = new MapClass($element, options) |
|
|
this.map = new MapClass($element, { ...baseOptions, ...ctx.settings }) |
|
|
|
|
|
|
|
|
this.schema = providerSets[mapProvider]?.schema; |
|
|
this.schema = providerSets[mapProvider]?.schema; |
|
|
} |
|
|
} |
|
|
@ -68,7 +70,7 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
|
|
|
|
|
|
|
onResize() { |
|
|
onResize() { |
|
|
this.map.onResize();//not work
|
|
|
this.map.onResize();//not work
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getSettingsSchema(): Object { |
|
|
getSettingsSchema(): Object { |
|
|
return this.schema; |
|
|
return this.schema; |
|
|
@ -84,74 +86,57 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static settingsSchema(mapProvider, drawRoutes): Object { |
|
|
public static settingsSchema(mapProvider, drawRoutes): Object { |
|
|
var schema; |
|
|
const providerInfo = providerSets[mapProvider]; |
|
|
if (mapProvider === 'google-map') { |
|
|
let schema = providerInfo.schema; |
|
|
schema = googleMapSettingsSchema; |
|
|
schema.groupInfoes = []; |
|
|
schema.groupInfoes = [{ |
|
|
|
|
|
"formIndex": 0, |
|
|
function addGroupInfo(title: string) { |
|
|
"GroupTitle": "Google Map Settings" |
|
|
schema.groupInfoes.push({ |
|
|
}]; |
|
|
"formIndex": schema.groupInfoes?.length || 0, |
|
|
} else if (mapProvider === 'openstreet-map') { |
|
|
"GroupTitle": title |
|
|
schema = deepClone(openstreetMapSettingsSchema); |
|
|
}); |
|
|
schema.groupInfoes = [{ |
|
|
|
|
|
"formIndex": 0, |
|
|
|
|
|
"GroupTitle": "Openstreet Map Settings" |
|
|
|
|
|
}]; |
|
|
|
|
|
} else if (mapProvider === 'image-map') { |
|
|
|
|
|
return imageMapSettingsSchema; |
|
|
|
|
|
} else if (mapProvider === 'tencent-map') { |
|
|
|
|
|
schema = deepClone(tencentMapSettingsSchema); |
|
|
|
|
|
schema.groupInfoes = [{ |
|
|
|
|
|
"formIndex": 0, |
|
|
|
|
|
"GroupTitle": "Tencent Map Settings" |
|
|
|
|
|
}]; |
|
|
|
|
|
} else if (mapProvider === 'here') { |
|
|
|
|
|
schema = deepClone(hereMapSettingsSchema); |
|
|
|
|
|
schema.groupInfoes = [{ |
|
|
|
|
|
"formIndex": 0, |
|
|
|
|
|
"GroupTitle": "Here Map Settings" |
|
|
|
|
|
}]; |
|
|
|
|
|
} |
|
|
} |
|
|
if (!schema.groupInfoes) schema.groupInfoes = []; |
|
|
|
|
|
|
|
|
function mergeSchema(newSchema) { |
|
|
|
|
|
Object.assign(schema.schema.properties, newSchema.schema.properties); |
|
|
|
|
|
schema.schema.required = schema.schema.required.concat(newSchema.schema.required); |
|
|
|
|
|
schema.form.push(newSchema.form);//schema.form.concat(commonMapSettingsSchema.form);
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (providerInfo.name) |
|
|
|
|
|
addGroupInfo(providerInfo.name + ' Map Settings'); |
|
|
schema.form = [schema.form]; |
|
|
schema.form = [schema.form]; |
|
|
|
|
|
|
|
|
Object.assign(schema.schema.properties, commonMapSettingsSchema.schema.properties); |
|
|
mergeSchema(commonMapSettingsSchema); |
|
|
schema.schema.required = schema.schema.required.concat(commonMapSettingsSchema.schema.required); |
|
|
addGroupInfo("Common Map Settings"); |
|
|
schema.form.push(commonMapSettingsSchema.form);//schema.form.concat(commonMapSettingsSchema.form);
|
|
|
|
|
|
schema.groupInfoes.push({ |
|
|
|
|
|
"formIndex": schema.groupInfoes.length, |
|
|
|
|
|
"GroupTitle": "Common Map Settings" |
|
|
|
|
|
}); |
|
|
|
|
|
if (drawRoutes) { |
|
|
if (drawRoutes) { |
|
|
Object.assign(schema.schema.properties, routeMapSettingsSchema.schema.properties); |
|
|
mergeSchema(routeMapSettingsSchema); |
|
|
schema.schema.required = schema.schema.required.concat(routeMapSettingsSchema.schema.required); |
|
|
addGroupInfo("Route Map Settings"); |
|
|
schema.form.push(routeMapSettingsSchema.form);//schema.form = schema.form.concat(routeMapSettingsSchema.form);
|
|
|
|
|
|
schema.groupInfoes.push({ |
|
|
|
|
|
"formIndex": schema.groupInfoes.length, |
|
|
|
|
|
"GroupTitle": "Route Map Settings" |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (mapProvider !== 'image-map') { |
|
|
} else if (mapProvider !== 'image-map') { |
|
|
Object.assign(schema.schema.properties, markerClusteringSettingsSchema.schema.properties); |
|
|
let clusteringSchema: any = { |
|
|
schema.schema.required = schema.schema.required.concat(markerClusteringSettingsSchema.schema.required); |
|
|
schema: { |
|
|
schema.form.push(markerClusteringSettingsSchema.form); |
|
|
properties: { |
|
|
if (mapProvider === 'google-map' || mapProvider === 'tencent-map') { |
|
|
...markerClusteringSettingsSchemaLeaflet.schema.properties, |
|
|
Object.assign(schema.schema.properties, markerClusteringSettingsSchemaGoogle.schema.properties); |
|
|
...markerClusteringSettingsSchema.schema.properties |
|
|
schema.schema.required = schema.schema.required.concat(markerClusteringSettingsSchemaGoogle.schema.required); |
|
|
}, |
|
|
schema.form[schema.form.length - 1] = schema.form[schema.form.length - 1].concat(markerClusteringSettingsSchemaGoogle.form); |
|
|
required: { |
|
|
} |
|
|
...markerClusteringSettingsSchemaLeaflet.schema.required, |
|
|
if (mapProvider === 'openstreet-map' || mapProvider === 'here') { |
|
|
...markerClusteringSettingsSchema.schema.required |
|
|
Object.assign(schema.schema.properties, markerClusteringSettingsSchemaLeaflet.schema.properties); |
|
|
} |
|
|
schema.schema.required = schema.schema.required.concat(markerClusteringSettingsSchemaLeaflet.schema.required); |
|
|
}, |
|
|
schema.form[schema.form.length - 1] = schema.form[schema.form.length - 1].concat(markerClusteringSettingsSchemaLeaflet.form); |
|
|
form: [ |
|
|
} |
|
|
...markerClusteringSettingsSchemaLeaflet.form, |
|
|
schema.groupInfoes.push({ |
|
|
...markerClusteringSettingsSchema.form |
|
|
"formIndex": schema.groupInfoes.length, |
|
|
] |
|
|
"GroupTitle": "Markers Clustering Settings" |
|
|
}; |
|
|
}); |
|
|
mergeSchema(clusteringSchema); |
|
|
|
|
|
addGroupInfo("Markers Clustering Settings"); |
|
|
} |
|
|
} |
|
|
return schema; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return schema; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static actionSources(): Object { |
|
|
public static actionSources(): Object { |
|
|
return { |
|
|
return { |
|
|
'markerClick': { |
|
|
'markerClick': { |
|
|
@ -168,10 +153,9 @@ TbMapWidgetV2 = class TbMapWidgetV2 implements MapWidgetInterface { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onDestroy() { |
|
|
onDestroy() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let defaultSettings = { |
|
|
let defaultSettings = { |
|
|
|