PageSourceSearch

https://dubaienergy.netlify.app/js/L.VisualClick.js

js dubaienergy.netlify.app collected 2026-10-03 10:40:15 UTC 2,499 bytes, 73 lines download raw bytes

1/*
2* L.VisualClick
3* Description: A plugin that adds visual feedback when user clicks/taps the map. Useful for when you have a delay on the clickEvents for async fetching of data, or implmentation of Leaflet.singleclick
4* Example: L.visualClick({map: leafletMap}); //Just works
5* Author: Dag Jomar Mersland (twitter: @dagjomar)
6*/
7
8
9L.Map.VisualClick = L.Handler.extend({
10
11    _makeVisualIcon: function(){
12
13        var touchMode = this._map.options.visualClickMode === 'touch' ? true : false;
14
15        return L.divIcon({
16            className: "leaflet-visualclick-icon" + (touchMode ? '-touch' : ''),    // See L.VisualClick.css
17            iconSize: [0, 0],
18            clickable: false
19        });
20    },
21
22    _visualIcon: null,
23
24    _onClick: function(e) {
25
26        var map = this._map;
27
28        var latlng = e.latlng;
29        var marker = L.marker(latlng, {
30            pane: this._map.options.visualClickPane,
31            icon: this._visualIcon,
32            interactive: false
33        }).addTo(map);
34
35        window.setTimeout(function(){
36            if(map){
37                map.removeLayer(marker);
38            }
39        }.bind(this), map.options.visualClick.removeTimeout || 450);    // Should somewhat match the css animation to prevent loops
40
41        return true;
42    },
43
44    addHooks: function () {
45        if(this._visualIcon === null){
46            this._visualIcon = this._makeVisualIcon();
47        }
48
49        if (this._map.options.visualClickPane === 'ie10-visual-click-pane') {
50            this._map.createPane('ie10-visual-click-pane');
51        }
52
53        this._map.on(this._map.options.visualClickEvents, this._onClick, this);
54    },
55
56    removeHooks: function () {
57        this._map.off(this._map.options.visualClickEvents, this._onClick, this);
58    },
59
60});
61
62
63L.Map.mergeOptions({
64    visualClick: L.Browser.any3d ? true : false, //Can be true, desktop, touch, false. Not straight forward to use L.Browser.touch flag because true on IE10
65    visualClickMode: L.Browser.touch && L.Browser.mobile ? 'touch' : 'desktop', //Not straight forward to use only L.Browser.touch flag because true on IE10 - so this is slightly better
66    visualClickEvents: 'click contextmenu', //Standard leaflety way of defining which events to hook on to
67    visualClickPane: (L.Browser.ie && document.documentMode === 10) ?
68        'ie10-visual-click-pane' :
69        'shadowPane'	// Map pane where the pulse markers will be showh
70});
71
72L.Map.addInitHook('addHandler', 'visualClick', L.Map.VisualClick);
73

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.