1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1 50 50 50 50 50 50 100 100 100 100 100 100 100 36 36 36 36 1 36 1 1 50 50 50 1 | /* * L.Control.Zoom is used for the default zoom buttons on the map. */ L.Control.Zoom = L.Control.extend({ options: { position: 'topleft' }, onAdd: function (map) { var zoomName = 'leaflet-control-zoom', container = L.DomUtil.create('div', zoomName + ' leaflet-bar'); this._map = map; this._zoomInButton = this._createButton( '+', 'Zoom in', zoomName + '-in', container, this._zoomIn, this); this._zoomOutButton = this._createButton( '-', 'Zoom out', zoomName + '-out', container, this._zoomOut, this); map.on('zoomend zoomlevelschange', this._updateDisabled, this); return container; }, onRemove: function (map) { map.off('zoomend zoomlevelschange', this._updateDisabled, this); }, _zoomIn: function (e) { this._map.zoomIn(e.shiftKey ? 3 : 1); }, _zoomOut: function (e) { this._map.zoomOut(e.shiftKey ? 3 : 1); }, _createButton: function (html, title, className, container, fn, context) { var link = L.DomUtil.create('a', className, container); link.innerHTML = html; link.href = '#'; link.title = title; var stop = L.DomEvent.stopPropagation; L.DomEvent .on(link, 'click', stop) .on(link, 'mousedown', stop) .on(link, 'dblclick', stop) .on(link, 'click', L.DomEvent.preventDefault) .on(link, 'click', fn, context); return link; }, _updateDisabled: function () { var map = this._map, className = 'leaflet-disabled'; L.DomUtil.removeClass(this._zoomInButton, className); L.DomUtil.removeClass(this._zoomOutButton, className); if (map._zoom === map.getMinZoom()) { L.DomUtil.addClass(this._zoomOutButton, className); } Iif (map._zoom === map.getMaxZoom()) { L.DomUtil.addClass(this._zoomInButton, className); } } }); L.Map.mergeOptions({ zoomControl: true }); L.Map.addInitHook(function () { Eif (this.options.zoomControl) { this.zoomControl = new L.Control.Zoom(); this.addControl(this.zoomControl); } }); L.control.zoom = function (options) { return new L.Control.Zoom(options); }; |