Loading README.md +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ update your `composer.json` as below: }, "require": { "drupal/leaflet": "3.0.x-dev", "npm-asset/drustack--leaflet.resetview": "~1.0", "npm-asset/drustack--leaflet.resetview": "~1.1", "npm-asset/drustack--leaflet.syncview": "~1.0", "npm-asset/geoman-io--leaflet-geoman-free": "~2.11", "npm-asset/leaflet": "~1.7", Loading config/schema/leaflet.schema.yml +19 −19 Original line number Diff line number Diff line Loading @@ -99,19 +99,19 @@ field.widget.settings.leaflet_widget_default: rotateMode: type: boolean label: 'Rotate Mode' reset_map: fullscreen: type: mapping label: 'Reset map' label: 'Leaflet Fullscreen' mapping: position: type: string label: 'Position' control: type: boolean label: 'Control' fullscreen: options: type: text label: 'Options' locate: type: mapping label: 'Leaflet Fullscreen' label: 'Leaflet Locate' mapping: control: type: boolean Loading @@ -119,9 +119,9 @@ field.widget.settings.leaflet_widget_default: options: type: text label: 'Options' locate: resetview: type: mapping label: 'Leaflet Locate' label: 'Leaflet Reset View' mapping: control: type: boolean Loading Loading @@ -203,16 +203,6 @@ field.formatter.settings.leaflet_formatter_default: gesture_handling: type: boolean label: 'Gesture handling' reset_map: type: mapping label: 'Reset map' mapping: control: type: boolean label: 'Control' position: type: string label: 'Position' popup: type: boolean label: 'Popup' Loading Loading @@ -359,6 +349,16 @@ field.formatter.settings.leaflet_formatter_default: options: type: text label: 'Options' resetview: type: mapping label: 'Leaflet Reset View' mapping: control: type: boolean label: 'Control' options: type: text label: 'Options' path: type: text label: 'Path' Loading js/leaflet.drupal.js +9 −49 Original line number Diff line number Diff line Loading @@ -60,12 +60,15 @@ Drupal.Leaflet[mapid].start_zoom = Drupal.Leaflet[mapid].lMap.getZoom(); } // Add the Map Reset Control if requested. if (settings.settings.reset_map && settings.settings.reset_map.control && !Drupal.Leaflet[mapid].reset_control) { // Create the DIV to hold the control and call the mapResetControl() // constructor passing in this DIV. let mapResetControlDiv = document.createElement('div'); Drupal.Leaflet[mapid].reset_control = Drupal.Leaflet.prototype.map_reset_control(mapResetControlDiv, mapid).addTo(Drupal.Leaflet[mapid].lMap); // Add the Reset View Control if requested. if (settings.settings.resetview && settings.settings.resetview.control && !Drupal.Leaflet[mapid].resetview_control) { Drupal.Leaflet[mapid].resetview_control = L.control.resetView( JSON.parse(settings.settings.resetview.options) ).addTo(Drupal.Leaflet[mapid].lMap); L.Util.setOptions(Drupal.Leaflet[mapid].resetview_control, { latlng: Drupal.Leaflet[mapid].start_center, zoom: Drupal.Leaflet[mapid].start_zoom, }); } // Add the Map Geocoder Control if requested. Loading Loading @@ -622,47 +625,4 @@ }; Drupal.Leaflet.prototype.map_reset = function(mapid) { Drupal.Leaflet[mapid].lMap.setView(Drupal.Leaflet[mapid].start_center, Drupal.Leaflet[mapid].start_zoom); }; Drupal.Leaflet.prototype.map_reset_control = function(controlDiv, mapid) { let self = this; let reset_map_control_settings = drupalSettings.leaflet[mapid].map.settings.reset_map; let control = new L.Control({position: reset_map_control_settings.position}); control.onAdd = function() { // Set CSS for the control border. let controlUI = L.DomUtil.create('div','resetzoom'); controlUI.style.backgroundColor = '#fff'; controlUI.style.border = '2px solid #fff'; controlUI.style.borderRadius = '3px'; controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)'; controlUI.style.cursor = 'pointer'; controlUI.style.margin = '6px'; controlUI.style.textAlign = 'center'; controlUI.title = Drupal.t('Click to reset the map to its initial state'); controlUI.id = 'leaflet-map--' + mapid + '--reset-control'; controlUI.disabled = true; controlDiv.appendChild(controlUI); // Set CSS for the control interior. let controlText = document.createElement('div'); controlText.style.color = 'rgb(25,25,25)'; controlText.style.fontSize = '1.1em'; controlText.style.lineHeight = '28px'; controlText.style.paddingLeft = '5px'; controlText.style.paddingRight = '5px'; controlText.innerHTML = Drupal.t('Reset Map'); controlUI.appendChild(controlText); L.DomEvent .disableClickPropagation(controlUI) .addListener(controlUI, 'click', function() { self.map_reset(mapid); },controlUI); return controlUI; }; return control; }; })(jQuery, Drupal, drupalSettings); js/leaflet.widget.js +6 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,12 @@ Drupal.Leaflet[this.settings.map_id].start_zoom = start_zoom; Drupal.Leaflet[this.settings.map_id].start_center = start_center; if (Drupal.Leaflet[this.settings.map_id].resetview_control) { L.Util.setOptions(Drupal.Leaflet[this.settings.map_id].resetview_control, { latlng: start_center, zoom: start_zoom, }); } } } catch (error) { if (window.console) console.error(error.message); Loading leaflet.libraries.yml +12 −0 Original line number Diff line number Diff line Loading @@ -117,5 +117,17 @@ leaflet.locate: /libraries/leaflet.locatecontrol/dist/L.Control.Locate.min.css: { minified: true } js: /libraries/leaflet.locatecontrol/dist/L.Control.Locate.min.js: { minified: true } leaflet.resetview: remote: https://github.com/drustack/Leaflet.ResetView license: name: Apache-2.0 url: https://raw.githubusercontent.com/drustack/Leaflet.ResetView/master/LICENSE gpl-compatible: yes css: component: /libraries/drustack--leaflet.resetview/dist/L.Control.ResetView.min.css: { minified: true } js: /libraries/drustack--leaflet.resetview/dist/L.Control.ResetView.min.js: { minified: true } dependencies: - leaflet/leaflet Loading
README.md +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ update your `composer.json` as below: }, "require": { "drupal/leaflet": "3.0.x-dev", "npm-asset/drustack--leaflet.resetview": "~1.0", "npm-asset/drustack--leaflet.resetview": "~1.1", "npm-asset/drustack--leaflet.syncview": "~1.0", "npm-asset/geoman-io--leaflet-geoman-free": "~2.11", "npm-asset/leaflet": "~1.7", Loading
config/schema/leaflet.schema.yml +19 −19 Original line number Diff line number Diff line Loading @@ -99,19 +99,19 @@ field.widget.settings.leaflet_widget_default: rotateMode: type: boolean label: 'Rotate Mode' reset_map: fullscreen: type: mapping label: 'Reset map' label: 'Leaflet Fullscreen' mapping: position: type: string label: 'Position' control: type: boolean label: 'Control' fullscreen: options: type: text label: 'Options' locate: type: mapping label: 'Leaflet Fullscreen' label: 'Leaflet Locate' mapping: control: type: boolean Loading @@ -119,9 +119,9 @@ field.widget.settings.leaflet_widget_default: options: type: text label: 'Options' locate: resetview: type: mapping label: 'Leaflet Locate' label: 'Leaflet Reset View' mapping: control: type: boolean Loading Loading @@ -203,16 +203,6 @@ field.formatter.settings.leaflet_formatter_default: gesture_handling: type: boolean label: 'Gesture handling' reset_map: type: mapping label: 'Reset map' mapping: control: type: boolean label: 'Control' position: type: string label: 'Position' popup: type: boolean label: 'Popup' Loading Loading @@ -359,6 +349,16 @@ field.formatter.settings.leaflet_formatter_default: options: type: text label: 'Options' resetview: type: mapping label: 'Leaflet Reset View' mapping: control: type: boolean label: 'Control' options: type: text label: 'Options' path: type: text label: 'Path' Loading
js/leaflet.drupal.js +9 −49 Original line number Diff line number Diff line Loading @@ -60,12 +60,15 @@ Drupal.Leaflet[mapid].start_zoom = Drupal.Leaflet[mapid].lMap.getZoom(); } // Add the Map Reset Control if requested. if (settings.settings.reset_map && settings.settings.reset_map.control && !Drupal.Leaflet[mapid].reset_control) { // Create the DIV to hold the control and call the mapResetControl() // constructor passing in this DIV. let mapResetControlDiv = document.createElement('div'); Drupal.Leaflet[mapid].reset_control = Drupal.Leaflet.prototype.map_reset_control(mapResetControlDiv, mapid).addTo(Drupal.Leaflet[mapid].lMap); // Add the Reset View Control if requested. if (settings.settings.resetview && settings.settings.resetview.control && !Drupal.Leaflet[mapid].resetview_control) { Drupal.Leaflet[mapid].resetview_control = L.control.resetView( JSON.parse(settings.settings.resetview.options) ).addTo(Drupal.Leaflet[mapid].lMap); L.Util.setOptions(Drupal.Leaflet[mapid].resetview_control, { latlng: Drupal.Leaflet[mapid].start_center, zoom: Drupal.Leaflet[mapid].start_zoom, }); } // Add the Map Geocoder Control if requested. Loading Loading @@ -622,47 +625,4 @@ }; Drupal.Leaflet.prototype.map_reset = function(mapid) { Drupal.Leaflet[mapid].lMap.setView(Drupal.Leaflet[mapid].start_center, Drupal.Leaflet[mapid].start_zoom); }; Drupal.Leaflet.prototype.map_reset_control = function(controlDiv, mapid) { let self = this; let reset_map_control_settings = drupalSettings.leaflet[mapid].map.settings.reset_map; let control = new L.Control({position: reset_map_control_settings.position}); control.onAdd = function() { // Set CSS for the control border. let controlUI = L.DomUtil.create('div','resetzoom'); controlUI.style.backgroundColor = '#fff'; controlUI.style.border = '2px solid #fff'; controlUI.style.borderRadius = '3px'; controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)'; controlUI.style.cursor = 'pointer'; controlUI.style.margin = '6px'; controlUI.style.textAlign = 'center'; controlUI.title = Drupal.t('Click to reset the map to its initial state'); controlUI.id = 'leaflet-map--' + mapid + '--reset-control'; controlUI.disabled = true; controlDiv.appendChild(controlUI); // Set CSS for the control interior. let controlText = document.createElement('div'); controlText.style.color = 'rgb(25,25,25)'; controlText.style.fontSize = '1.1em'; controlText.style.lineHeight = '28px'; controlText.style.paddingLeft = '5px'; controlText.style.paddingRight = '5px'; controlText.innerHTML = Drupal.t('Reset Map'); controlUI.appendChild(controlText); L.DomEvent .disableClickPropagation(controlUI) .addListener(controlUI, 'click', function() { self.map_reset(mapid); },controlUI); return controlUI; }; return control; }; })(jQuery, Drupal, drupalSettings);
js/leaflet.widget.js +6 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,12 @@ Drupal.Leaflet[this.settings.map_id].start_zoom = start_zoom; Drupal.Leaflet[this.settings.map_id].start_center = start_center; if (Drupal.Leaflet[this.settings.map_id].resetview_control) { L.Util.setOptions(Drupal.Leaflet[this.settings.map_id].resetview_control, { latlng: start_center, zoom: start_zoom, }); } } } catch (error) { if (window.console) console.error(error.message); Loading
leaflet.libraries.yml +12 −0 Original line number Diff line number Diff line Loading @@ -117,5 +117,17 @@ leaflet.locate: /libraries/leaflet.locatecontrol/dist/L.Control.Locate.min.css: { minified: true } js: /libraries/leaflet.locatecontrol/dist/L.Control.Locate.min.js: { minified: true } leaflet.resetview: remote: https://github.com/drustack/Leaflet.ResetView license: name: Apache-2.0 url: https://raw.githubusercontent.com/drustack/Leaflet.ResetView/master/LICENSE gpl-compatible: yes css: component: /libraries/drustack--leaflet.resetview/dist/L.Control.ResetView.min.css: { minified: true } js: /libraries/drustack--leaflet.resetview/dist/L.Control.ResetView.min.js: { minified: true } dependencies: - leaflet/leaflet