PageSourceSearch

https://eacopmap.org/lib/leaflet/leaflet-mouseposition.js

js eacopmap.org collected 2026-10-07 06:32:13 UTC 1,532 bytes, 48 lines download raw bytes

1L.Control.MousePosition = L.Control.extend({
2  options: {
3    position: 'bottomleft',
4    separator: ' : ',
5    emptyString: '0.00000 : 0.00000',
6    lngFirst: false,
7    numDigits: 5,
8    lngFormatter: undefined,
9    latFormatter: undefined,
10    prefix: ""
11  },
12
13  onAdd: function (map) {
14    this._container = L.DomUtil.create('div', 'leaflet-control-mouseposition');
15    L.DomEvent.disableClickPropagation(this._container);
16    map.on('mousemove', this._onMouseMove, this);
17    this._container.innerHTML=this.options.emptyString;
18    return this._container;
19  },
20
21  onRemove: function (map) {
22    map.off('mousemove', this._onMouseMove)
23  },
24
25  _onMouseMove: function (e) {
26    var lng = this.options.lngFormatter ? this.options.lngFormatter(e.latlng.lng) : L.Util.formatNum(e.latlng.lng, this.options.numDigits);
27    var lat = this.options.latFormatter ? this.options.latFormatter(e.latlng.lat) : L.Util.formatNum(e.latlng.lat, this.options.numDigits);
28    var value = this.options.lngFirst ? lng + this.options.separator + lat : lat + this.options.separator + lng;
29    var prefixAndValue = this.options.prefix + ' ' + value;
30    this._container.innerHTML = prefixAndValue;
31  }
32
33});
34
35L.Map.mergeOptions({
36    positionControl: false
37});
38
39L.Map.addInitHook(function () {
40    if (this.options.positionControl) {
41        this.positionControl = new L.Control.MousePosition();
42        this.addControl(this.positionControl);
43    }
44});
45
46L.control.mousePosition = function (options) {
47    return new L.Control.MousePosition(options);
48};

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.