|
|
@ -158,9 +158,9 @@ export default abstract class LeafletMap { |
|
|
this.map = map; |
|
|
this.map = map; |
|
|
if (this.options.useDefaultCenterPosition) { |
|
|
if (this.options.useDefaultCenterPosition) { |
|
|
this.map.panTo(this.options.defaultCenterPosition); |
|
|
this.map.panTo(this.options.defaultCenterPosition); |
|
|
this.bounds = map.getBounds(); |
|
|
this.bounds = map.getBounds(); |
|
|
} |
|
|
} |
|
|
else this.bounds = new L.LatLngBounds(null, null); |
|
|
else this.bounds = new L.LatLngBounds(null, null); |
|
|
if (this.options.draggableMarker) { |
|
|
if (this.options.draggableMarker) { |
|
|
this.addMarkerControl(); |
|
|
this.addMarkerControl(); |
|
|
} |
|
|
} |
|
|
@ -279,8 +279,8 @@ export default abstract class LeafletMap { |
|
|
private createMarker(key: string, data: FormattedData, dataSources: FormattedData[], settings: MarkerSettings, callback?) { |
|
|
private createMarker(key: string, data: FormattedData, dataSources: FormattedData[], settings: MarkerSettings, callback?) { |
|
|
this.ready$.subscribe(() => { |
|
|
this.ready$.subscribe(() => { |
|
|
const newMarker = new Marker(this.convertPosition(data), settings, data, dataSources, this.dragMarker); |
|
|
const newMarker = new Marker(this.convertPosition(data), settings, data, dataSources, this.dragMarker); |
|
|
if(callback) |
|
|
if (callback) |
|
|
newMarker.leafletMarker.on('click', ()=>{callback(data, true)}); |
|
|
newMarker.leafletMarker.on('click', () => { callback(data, true) }); |
|
|
if (this.bounds) |
|
|
if (this.bounds) |
|
|
this.fitBounds(this.bounds.extend(newMarker.leafletMarker.getLatLng())); |
|
|
this.fitBounds(this.bounds.extend(newMarker.leafletMarker.getLatLng())); |
|
|
this.markers.set(key, newMarker); |
|
|
this.markers.set(key, newMarker); |
|
|
@ -373,8 +373,12 @@ export default abstract class LeafletMap { |
|
|
updatePolyline(key: string, data: FormattedData[], dataSources: FormattedData[], settings: PolylineSettings) { |
|
|
updatePolyline(key: string, data: FormattedData[], dataSources: FormattedData[], settings: PolylineSettings) { |
|
|
this.ready$.subscribe(() => { |
|
|
this.ready$.subscribe(() => { |
|
|
const poly = this.polylines.get(key); |
|
|
const poly = this.polylines.get(key); |
|
|
|
|
|
const oldBounds = poly.leafletPoly.getBounds(); |
|
|
poly.updatePolyline(settings, data.map(el => this.convertPosition(el)), dataSources); |
|
|
poly.updatePolyline(settings, data.map(el => this.convertPosition(el)), dataSources); |
|
|
const bounds = poly.leafletPoly.getBounds(); |
|
|
const newBounds = poly.leafletPoly.getBounds(); |
|
|
|
|
|
if (oldBounds.toBBoxString() !== newBounds.toBBoxString()) { |
|
|
|
|
|
this.fitBounds(newBounds); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -408,7 +412,12 @@ export default abstract class LeafletMap { |
|
|
updatePolygon(polyData: FormattedData, dataSources: FormattedData[], settings: PolygonSettings) { |
|
|
updatePolygon(polyData: FormattedData, dataSources: FormattedData[], settings: PolygonSettings) { |
|
|
this.ready$.subscribe(() => { |
|
|
this.ready$.subscribe(() => { |
|
|
const poly = this.polygons.get(polyData.entityName); |
|
|
const poly = this.polygons.get(polyData.entityName); |
|
|
|
|
|
const oldBounds = poly.leafletPoly.getBounds(); |
|
|
poly.updatePolygon(polyData, dataSources, settings); |
|
|
poly.updatePolygon(polyData, dataSources, settings); |
|
|
|
|
|
const newBounds = poly.leafletPoly.getBounds(); |
|
|
|
|
|
if (oldBounds.toBBoxString() !== newBounds.toBBoxString()) { |
|
|
|
|
|
this.fitBounds(newBounds); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|