]> git.openstreetmap.org Git - rails.git/commitdiff
Update leaflet plugins
authorTom Hughes <tom@compton.nu>
Wed, 1 Apr 2020 08:24:44 +0000 (09:24 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 1 Apr 2020 08:24:44 +0000 (09:24 +0100)
Vendorfile
vendor/assets/leaflet/leaflet.contextmenu.js
vendor/assets/leaflet/leaflet.locate.js
vendor/assets/leaflet/leaflet.polyline.js

index f0a13f416b303237cd8223043651da968aa4d38c..36716646e95e2a1bd3c4d8e4c93639e0a4fbaf71 100644 (file)
@@ -20,7 +20,7 @@ folder 'vendor/assets' do
       file "images/#{image}", "https://unpkg.com/leaflet@1.6.0/dist/images/#{image}"
     end
 
-    from 'git://github.com/aratcliffe/Leaflet.contextmenu.git', :tag => 'v1.5.0' do
+    from 'git://github.com/aratcliffe/Leaflet.contextmenu.git', :tag => 'v1.5.1' do
       file 'leaflet.contextmenu.js', 'dist/leaflet.contextmenu.js'
       file 'leaflet.contextmenu.css', 'dist/leaflet.contextmenu.css'
     end
@@ -31,7 +31,7 @@ folder 'vendor/assets' do
       folder 'img', 'src/img'
     end
 
-    from 'git://github.com/domoritz/leaflet-locatecontrol.git', :tag => 'v0.66.0' do
+    from 'git://github.com/domoritz/leaflet-locatecontrol.git', :tag => 'v0.71.0' do
       file 'leaflet.locate.js', 'src/L.Control.Locate.js'
     end
 
@@ -39,7 +39,7 @@ folder 'vendor/assets' do
       file 'leaflet.osm.js', 'leaflet-osm.js'
     end
 
-    from 'git://github.com/jieter/Leaflet.encoded.git', :tag => '0.0.8' do
+    from 'git://github.com/jieter/Leaflet.encoded.git', :tag => '0.0.9' do
       file 'leaflet.polyline.js', 'Polyline.encoded.js'
     end
   end
index 58cd4d7bfb6b5568fddd7cea51ff15fac4e7e45c..489da8755b551c9033efabaf5d9c9ac400af4f13 100644 (file)
@@ -29,14 +29,14 @@ L.Map.mergeOptions({
 
 L.Map.ContextMenu = L.Handler.extend({
     _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',
-    
+
     statics: {
         BASE_CLS: 'leaflet-contextmenu'
     },
-    
+
     initialize: function (map) {
         L.Handler.prototype.initialize.call(this, map);
-        
+
         this._items = [];
         this._visible = false;
 
@@ -71,7 +71,6 @@ L.Map.ContextMenu = L.Handler.extend({
         this._map.on({
             contextmenu: this._show,
             mousedown: this._hide,
-            movestart: this._hide,
             zoomstart: this._hide
         }, this);
     },
@@ -90,7 +89,6 @@ L.Map.ContextMenu = L.Handler.extend({
         this._map.off({
             contextmenu: this._show,
             mousedown: this._hide,
-            movestart: this._hide,
             zoomstart: this._hide
         }, this);
     },
@@ -320,12 +318,24 @@ L.Map.ContextMenu = L.Handler.extend({
                 return;
             }
 
+            var map = me._map,
+                containerPoint = me._showLocation.containerPoint,
+                layerPoint = map.containerPointToLayerPoint(containerPoint),
+                latlng = map.layerPointToLatLng(layerPoint),
+                relatedTarget = me._showLocation.relatedTarget,
+                data = {
+                  containerPoint: containerPoint,
+                  layerPoint: layerPoint,
+                  latlng: latlng,
+                  relatedTarget: relatedTarget
+                };
+
             if (hideOnSelect) {
                 me._hide();
             }
 
             if (func) {
-                func.call(context || map, me._showLocation);
+                func.call(context || map, data);
             }
 
             me._map.fire('contextmenu.select', {
@@ -361,13 +371,9 @@ L.Map.ContextMenu = L.Handler.extend({
     _showAtPoint: function (pt, data) {
         if (this._items.length) {
             var map = this._map,
-            layerPoint = map.containerPointToLayerPoint(pt),
-            latlng = map.layerPointToLatLng(layerPoint),
             event = L.extend(data || {}, {contextmenu: this});
 
             this._showLocation = {
-                latlng: latlng,
-                layerPoint: layerPoint,
                 containerPoint: pt
             };
 
index 615b4654baf0332145a524479704c18cf73f6414..99aa3433712beeb5f34a986cfea073fffc45e9d7 100644 (file)
@@ -133,7 +133,7 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
             '<path d="'+path+'" style="'+style+'" />'+
             '</svg>';
             return {
-                className: 'leafet-control-locate-heading',
+                className: 'leaflet-control-locate-heading',
                 svg: svg,
                 w: w,
                 h: h
@@ -168,6 +168,8 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
             setView: 'untilPanOrZoom',
             /** Keep the current map zoom level when setting the view and only pan. */
             keepCurrentZoomLevel: false,
+           /** After activating the plugin by clicking on the icon, zoom to the selected zoom level, even when keepCurrentZoomLevel is true. Set to 'false' to disable this feature. */
+           initialZoomLevel: false,
             /**
              * This callback can be used to override the viewport tracking
              * This function should return a LatLngBounds object.
@@ -467,10 +469,21 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
                 this._map.on('zoomstart', this._onZoom, this);
                 this._map.on('zoomend', this._onZoomEnd, this);
                 if (this.options.showCompass) {
-                    if ('ondeviceorientationabsolute' in window) {
-                        L.DomEvent.on(window, 'deviceorientationabsolute', this._onDeviceOrientation, this);
-                    } else if ('ondeviceorientation' in window) {
-                        L.DomEvent.on(window, 'deviceorientation', this._onDeviceOrientation, this);
+                    var oriAbs = 'ondeviceorientationabsolute' in window;
+                    if (oriAbs || ('ondeviceorientation' in window)) {
+                        var _this = this;
+                        var deviceorientation = function () {
+                            L.DomEvent.on(window, oriAbs ? 'deviceorientationabsolute' : 'deviceorientation', _this._onDeviceOrientation, _this);
+                        };
+                        if (DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission === 'function') {
+                            DeviceOrientationEvent.requestPermission().then(function (permissionState) {
+                                if (permissionState === 'granted') {
+                                    deviceorientation();
+                                }
+                            })
+                        } else {
+                            deviceorientation();
+                        }
                     }
                 }
             }
@@ -514,6 +527,10 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
                 this._event = undefined;  // clear the current location so we can get back into the bounds
                 this.options.onLocationOutsideMapBounds(this);
             } else {
+               if (this._justClicked && this.options.initialZoomLevel !== false) {
+                    var f = this.options.flyTo ? this._map.flyTo : this._map.setView;
+                    f.bind(this._map)([this._event.latitude, this._event.longitude], this.options.initialZoomLevel);
+               } else
                 if (this.options.keepCurrentZoomLevel) {
                     var f = this.options.flyTo ? this._map.flyTo : this._map.panTo;
                     f.bind(this._map)([this._event.latitude, this._event.longitude]);
@@ -538,6 +555,10 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
          *
          */
         _drawCompass: function() {
+            if (!this._event) {
+                return;
+            }
+
             var latlng = this._event.latlng;
 
             if (this.options.showCompass && latlng && this._compassHeading !== null) {
@@ -610,14 +631,23 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
             this._drawCompass();
 
             var t = this.options.strings.popup;
+            function getPopupText() {
+                if (typeof t === 'string') {
+                    return L.Util.template(t, {distance: distance, unit: unit});
+                } else if (typeof t === 'function') {
+                    return t({distance: distance, unit: unit});
+                } else {
+                    return t;
+                }
+            }
             if (this.options.showPopup && t && this._marker) {
                 this._marker
-                    .bindPopup(L.Util.template(t, {distance: distance, unit: unit}))
+                    .bindPopup(getPopupText())
                     ._popup.setLatLng(latlng);
             }
             if (this.options.showPopup && t && this._compass) {
                 this._compass
-                    .bindPopup(L.Util.template(t, {distance: distance, unit: unit}))
+                    .bindPopup(getPopupText())
                     ._popup.setLatLng(latlng);
             }
         },
@@ -774,7 +804,7 @@ You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
 
             if (this._event && !this._ignoreEvent) {
                 // If we have zoomed in and out and ended up sideways treat it as a pan
-                if (!this._map.getBounds().pad(-.3).contains(this._marker.getLatLng())) {
+                if (this._marker && !this._map.getBounds().pad(-.3).contains(this._marker.getLatLng())) {
                     this._userPanned = true;
                     this._updateContainerStyle();
                     this._drawMarker();
index 772e7ebc61355e5973f281c47a1fd18ff1d1cb42..957f6cbda01f0706efb76aebb6cd4df98f2094d0 100644 (file)
@@ -78,7 +78,7 @@
 
             for (var i = 0, len = numbers.length; i < len;) {
                 for (var d = 0; d < options.dimension; ++d, ++i) {
-                    var num = numbers[i];
+                    var num = numbers[i].toFixed(options.precision);
                     var delta = num - (lastNumbers[d] || 0);
                     lastNumbers[d] = num;