|
|
|
@ -72,11 +72,26 @@ export function getMapOptions(geojson: GeoJSON.FeatureCollection) {
|
|
|
|
|
updateBounds(coordinates); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const addPoint = (feature: GeoJSON.Feature) => { |
|
|
|
|
const { geometry, properties } = feature; |
|
|
|
|
const { name } = properties as any; |
|
|
|
|
const { coordinates } = geometry as GeoJSON.Point; |
|
|
|
|
mapOptions.overlays.push({ |
|
|
|
|
id: getUID(), |
|
|
|
|
name, |
|
|
|
|
type: OverlayTypes.Point, |
|
|
|
|
lngLat: convertPosition(coordinates), |
|
|
|
|
}); |
|
|
|
|
updateBounds([coordinates]); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
features.forEach((feature) => { |
|
|
|
|
const { geometry } = feature; |
|
|
|
|
const { type } = geometry; |
|
|
|
|
if (type === "Polygon") { |
|
|
|
|
addPolygon(feature); |
|
|
|
|
} else if (type === "Point") { |
|
|
|
|
addPoint(feature); |
|
|
|
|
} else { |
|
|
|
|
addPolyline(feature); |
|
|
|
|
} |
|
|
|
@ -90,9 +105,11 @@ export function getMapOptions(geojson: GeoJSON.FeatureCollection) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function convertPath(path: GeoJSON.Position[]) { |
|
|
|
|
return path.map((pos) => { |
|
|
|
|
let [lng, lat] = pos; |
|
|
|
|
({ lng, lat } = gps84_To_gcj02(lng, lat)); |
|
|
|
|
return [lng, lat]; |
|
|
|
|
}); |
|
|
|
|
return path.map(convertPosition); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function convertPosition(position: GeoJSON.Position) { |
|
|
|
|
let [lng, lat] = position; |
|
|
|
|
({ lng, lat } = gps84_To_gcj02(lng, lat)); |
|
|
|
|
return [lng, lat]; |
|
|
|
|
} |
|
|
|
|