mapbox-gl-controls
Advanced tools
Comparing version 2.3.4 to 2.3.5
@@ -53,2 +53,3 @@ import { Marker } from 'mapbox-gl'; | ||
mapClickListener(event: any): void; | ||
updateSource(): void; | ||
updateLabels(): void; | ||
@@ -55,0 +56,0 @@ getMarkerNode(): HTMLDivElement; |
@@ -115,4 +115,2 @@ import mapboxgl from 'mapbox-gl'; | ||
const markerNode = this.getMarkerNode(); | ||
const lineSource = this.map.getSource(SOURCE_LINE); | ||
const symbolSource = this.map.getSource(SOURCE_SYMBOL); | ||
const marker = new mapboxgl.Marker({ element: markerNode, draggable: true }) | ||
@@ -123,7 +121,6 @@ .setLngLat(event.lngLat) | ||
this.coordinates.push(newCoordinate); | ||
this.map.fire('ruler.change', { coordinates: this.coordinates }); | ||
this.updateLabels(); | ||
lineSource.setData(lineStringFeature(this.coordinates)); | ||
symbolSource.setData(pointFeatureCollection(this.coordinates, this.labels)); | ||
this.updateSource(); | ||
this.markers.push(marker); | ||
this.map.fire('ruler.change', { coordinates: this.coordinates }); | ||
marker.on('drag', () => { | ||
@@ -134,6 +131,14 @@ const index = this.markers.indexOf(marker); | ||
this.updateLabels(); | ||
lineSource.setData(lineStringFeature(this.coordinates)); | ||
symbolSource.setData(pointFeatureCollection(this.coordinates, this.labels)); | ||
this.updateSource(); | ||
}); | ||
marker.on('dragend', () => { | ||
this.map.fire('ruler.change', { coordinates: this.coordinates }); | ||
}); | ||
} | ||
updateSource() { | ||
const lineSource = this.map.getSource(SOURCE_LINE); | ||
const symbolSource = this.map.getSource(SOURCE_SYMBOL); | ||
lineSource.setData(lineStringFeature(this.coordinates)); | ||
symbolSource.setData(pointFeatureCollection(this.coordinates, this.labels)); | ||
} | ||
updateLabels() { | ||
@@ -140,0 +145,0 @@ const { coordinates, units, labelFormat } = this; |
{ | ||
"name": "mapbox-gl-controls", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "description": "Controls for mapbox-gl", |
@@ -167,4 +167,3 @@ import mapboxgl, { GeoJSONSource, Marker } from 'mapbox-gl'; | ||
const markerNode = this.getMarkerNode(); | ||
const lineSource = this.map.getSource(SOURCE_LINE) as GeoJSONSource; | ||
const symbolSource = this.map.getSource(SOURCE_SYMBOL) as GeoJSONSource; | ||
const marker = new mapboxgl.Marker({ element: markerNode, draggable: true }) | ||
@@ -174,9 +173,7 @@ .setLngLat(event.lngLat) | ||
const newCoordinate = [event.lngLat.lng, event.lngLat.lat]; | ||
this.coordinates.push(newCoordinate); | ||
this.map.fire('ruler.change', { coordinates: this.coordinates }); | ||
this.updateLabels(); | ||
lineSource.setData(lineStringFeature(this.coordinates)); | ||
symbolSource.setData(pointFeatureCollection(this.coordinates, this.labels)); | ||
this.updateSource(); | ||
this.markers.push(marker); | ||
this.map.fire('ruler.change', { coordinates: this.coordinates }); | ||
@@ -188,7 +185,17 @@ marker.on('drag', () => { | ||
this.updateLabels(); | ||
lineSource.setData(lineStringFeature(this.coordinates)); | ||
symbolSource.setData(pointFeatureCollection(this.coordinates, this.labels)); | ||
this.updateSource(); | ||
}); | ||
marker.on('dragend', () => { | ||
this.map.fire('ruler.change', { coordinates: this.coordinates }); | ||
}); | ||
} | ||
updateSource() { | ||
const lineSource = this.map.getSource(SOURCE_LINE) as GeoJSONSource; | ||
const symbolSource = this.map.getSource(SOURCE_SYMBOL) as GeoJSONSource; | ||
lineSource.setData(lineStringFeature(this.coordinates)); | ||
symbolSource.setData(pointFeatureCollection(this.coordinates, this.labels)); | ||
} | ||
updateLabels() { | ||
@@ -195,0 +202,0 @@ const { coordinates, units, labelFormat } = this; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171852
3102