mirror of
https://github.com/maputnik/editor.git
synced 2025-12-25 15:40:00 +00:00
Merge remote-tracking branch 'upstream/master' into fix/update-deps
Conflicts: src/components/Toolbar.jsx
This commit is contained in:
26
src/libs/zoomcontrol.js
Normal file
26
src/libs/zoomcontrol.js
Normal file
@@ -0,0 +1,26 @@
|
||||
export default class ZoomControl {
|
||||
onAdd(map) {
|
||||
this._map = map;
|
||||
this._container = document.createElement('div');
|
||||
this._container.className = 'mapboxgl-ctrl mapboxgl-ctrl-group mapboxgl-ctrl-zoom';
|
||||
|
||||
this.addEventListeners();
|
||||
|
||||
return this._container;
|
||||
}
|
||||
|
||||
updateZoomLevel() {
|
||||
this._container.innerHTML = `Zoom level: ${this._map.getZoom().toFixed(2)}`;
|
||||
}
|
||||
|
||||
addEventListeners (){
|
||||
this._map.on('render', this.updateZoomLevel.bind(this) );
|
||||
this._map.on('zoomIn', this.updateZoomLevel.bind(this) );
|
||||
this._map.on('zoomOut', this.updateZoomLevel.bind(this) );
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this._container.parentNode.removeChild(this._container);
|
||||
this._map = undefined;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user