1/** 2 * (c) Wong Hoi Sing Edison <[email protected]> 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17(function (factory, window) { 18 if (typeof define === "function" && define.amd) { 19 define(["leaflet"], factory); 20 } else if (typeof exports === "object") { 21 module.exports = factory(require("leaflet")); 22 } 23 24 if (typeof window !== "undefined" && window.L) { 25 window.L.Control.ResetView = factory(L); 26 } 27}(function (L) { 28 ResetView = L.Control.extend({ 29 options: { 30 position: "topleft", 31 title: "Reset view", 32 latlng: null, 33 zoom: null, 34 }, 35 36 onAdd: function(map) { 37 this._map = map; 38 39 this._container = L.DomUtil.create("div", "leaflet-control-resetview leaflet-bar leaflet-control"); 40 this._link = L.DomUtil.create("a", "leaflet-bar-part leaflet-bar-part-single", this._container); 41 this._link.title = this.options.title; 42 this._link.href = "#"; 43 this._link.setAttribute("role", "button"); 44 this._icon = L.DomUtil.create("span", "leaflet-control-resetview-icon", this._link); 45 46 L.DomEvent.on(this._link, "click", this._resetView, this); 47 48 return this._container; 49 }, 50 51 onRemove: function(map) { 52 L.DomEvent.off(this._link, "click", this._resetView, this); 53 }, 54 55 _resetView: function(e) { 56 // Added by itamair according to this drustack/Leaflet.ResetView issue: 57 // https://github.com/drustack/Leaflet.ResetView/issues/1 58 if (e) { L.DomEvent.preventDefault(e) }
59 this._map.setView(this.options.latlng, this.options.zoom); 60 }, 61 }); 62 63 L.control.resetView = function(options) { 64 return new ResetView(options); 65 }; 66 67 return ResetView; 68}, window));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.