Commit 0e232371 authored by Italo Mairo's avatar Italo Mairo
Browse files

Revert "Issue #3254074 by hswong3i: Refine Reset Map with drustack/Leaflet.ResetView"

This reverts commit a8163b43.
parent 2ad27808
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ update your `composer.json` as below:
        },
        "require": {
            "drupal/leaflet": "3.0.x-dev",
            "npm-asset/drustack--leaflet.resetview": "~1.1",
            "npm-asset/drustack--leaflet.resetview": "~1.0",
            "npm-asset/drustack--leaflet.syncview": "~1.0",
            "npm-asset/geoman-io--leaflet-geoman-free": "~2.11",
            "npm-asset/leaflet": "~1.7",
+19 −19
Original line number Diff line number Diff line
@@ -99,19 +99,19 @@ field.widget.settings.leaflet_widget_default:
        rotateMode:
          type: boolean
          label: 'Rotate Mode'
    fullscreen:
    reset_map:
      type: mapping
      label: 'Leaflet Fullscreen'
      label: 'Reset map'
      mapping:
        position:
          type: string
          label: 'Position'
        control:
          type: boolean
          label: 'Control'
        options:
          type: text
          label: 'Options'
    locate:
    fullscreen:
      type: mapping
      label: 'Leaflet Locate'
      label: 'Leaflet Fullscreen'
      mapping:
        control:
          type: boolean
@@ -119,9 +119,9 @@ field.widget.settings.leaflet_widget_default:
        options:
          type: text
          label: 'Options'
    resetview:
    locate:
      type: mapping
      label: 'Leaflet Reset View'
      label: 'Leaflet Locate'
      mapping:
        control:
          type: boolean
@@ -203,6 +203,16 @@ 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'
@@ -349,16 +359,6 @@ 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'
+49 −9
Original line number Diff line number Diff line
@@ -60,15 +60,12 @@
        Drupal.Leaflet[mapid].start_zoom = Drupal.Leaflet[mapid].lMap.getZoom();
      }

      // 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 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 Map Geocoder Control if requested.
@@ -625,4 +622,47 @@

  };

  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);
+0 −6
Original line number Diff line number Diff line
@@ -234,12 +234,6 @@
        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);
+0 −12
Original line number Diff line number Diff line
@@ -117,17 +117,5 @@ 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