PluginProbe
Leaflet Map / 3.0.5
Leaflet Map v3.0.5
3.4.7 3.4.6 trunk 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.11.5 2.12.0 2.13.0 2.14.0 2.15.0 2.16.0 2.16.1 2.16.2 2.17.0 2.17.1 2.17.2 2.17.3 2.18.0 2.19.0 2.19.1 All 49 releases
leaflet-map / scripts / shortcode-helper.js

shortcode-helper.js in Leaflet Map 3.0.5, at scripts/shortcode-helper.js

62 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || [];
3 window.WPLeafletMapPlugin.push(initAdminShortcodes);
4
5 function initAdminShortcodes() {
6 var map_input = document.getElementById('map-shortcode');
7 var marker_input = document.getElementById('marker-shortcode');
8 var map_1 = window.WPLeafletMapPlugin.maps[0];
9 var marker_1 = window.WPLeafletMapPlugin.markers[0];
10
11 function update_marker() {
12 var latlng = marker_1.getLatLng();
13 marker_input.value =
14 '[leaflet-marker lat=' + latlng.lat + ' lng=' + latlng.lng + ']';
15 }
16
17 function update_map() {
18 var bounds = map_1.getBounds();
19 var latlng = bounds.getCenter();
20 map_input.value =
21 '[leaflet-map lat=' +
22 latlng.lat +
23 ' lng=' +
24 latlng.lng +
25 ' zoom=' +
26 map_1.getZoom() +
27 ']';
28
29 // update marker if outside of bounds
30 if (!bounds.contains(marker_1.getLatLng())) {
31 // move marker to center
32 marker_1.setLatLng(latlng);
33 }
34 }
35
36 marker_1.on('drag', update_marker);
37 map_1.on('move', update_map);
38
39 update_map();
40 update_marker();
41
42 if (map_input.addEventListener) {
43 map_input.addEventListener('click', function () {
44 this.select();
45 });
46
47 marker_input.addEventListener('click', function () {
48 this.select();
49 });
50 } else {
51 // IE 8
52 map_input.attachEvent('onclick', function () {
53 map_input.select();
54 });
55
56 marker_input.attachEvent('onclick', function () {
57 marker_input.select();
58 });
59 }
60 }
61 })();
62