leaflet-rotate 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/debug.js CHANGED
@@ -194,6 +194,8 @@ L.Rotate = {
194
194
  padInput.addEventListener('mousemove', L.Rotate.displayCenter.bind(this));
195
195
  padInput.addEventListener('change', L.Rotate.displayBounds.bind(this));
196
196
  padInput.addEventListener('mousemove', L.Rotate.displayBounds.bind(this));
197
+ padInput.addEventListener('change', L.Rotate.displayLayersBounds.bind(this));
198
+ padInput.addEventListener('mousemove', L.Rotate.displayLayersBounds.bind(this));
197
199
  padInput.addEventListener('change', L.Rotate.displayPixelBounds.bind(this));
198
200
  padInput.addEventListener('mousemove', L.Rotate.displayPixelBounds.bind(this));
199
201
 
@@ -203,6 +205,7 @@ L.Rotate = {
203
205
  map.on('rotate', this.updatePivotDot);
204
206
  map.on('moveend zoomend resetview rotate', this.displayCenter.bind(this));
205
207
  map.on('moveend zoomend resetview rotate', this.displayBounds.bind(this));
208
+ map.on('moveend zoomend resetview rotate', this.displayLayersBounds.bind(this));
206
209
  map.on('moveend zoomend resetview rotate', this.displayPixelBounds.bind(this));
207
210
 
208
211
  this.updatePixelOrigin.call(map);
@@ -210,6 +213,7 @@ L.Rotate = {
210
213
  this.updatePivotDot.call(map);
211
214
  this.displayCenter.call(this);
212
215
  this.displayBounds.call(this);
216
+ this.displayLayersBounds.call(this);
213
217
  this.displayPixelBounds.call(this);
214
218
 
215
219
  if (L.Browser.mobile) {
@@ -252,20 +256,24 @@ L.Rotate = {
252
256
  * Debug L.Map._pixelOrigin
253
257
  */
254
258
  updatePixelOrigin: function() {
259
+ if (this._pixelOrigin) {
255
260
  document.getElementById('ogx').innerHTML = this._pixelOrigin.x;
256
261
  document.getElementById('ogy').innerHTML = this._pixelOrigin.y;
257
262
  this.___rotatePixelOrigin.style.left = (-this._pixelOrigin.x - 1) + 'px';
258
263
  this.___rotatePixelOrigin.style.top = (-this._pixelOrigin.y - 1) + 'px';
264
+ }
259
265
  },
260
266
 
261
267
  /**
262
268
  * Debug L.Map._pivot
263
269
  */
264
270
  updatePivotDot: function() {
271
+ if (this._pivot) {
265
272
  document.getElementById('pvx').innerHTML = this._pivot.x;
266
273
  document.getElementById('pvy').innerHTML = this._pivot.y;
267
274
  this.___rotatePivotDot.style.left = (this._pivot.x - 1) + 'px';
268
275
  this.___rotatePivotDot.style.top = (this._pivot.y - 1) + 'px';
276
+ }
269
277
  },
270
278
 
271
279
  /**
@@ -330,7 +338,7 @@ L.Rotate = {
330
338
  var lngSpan = northEast.lng - southWest.lng;
331
339
  var latSpan = northEast.lat - southWest.lat;
332
340
  var m = L.marker( L.latLng(southWest.lat + latSpan * Math.random(), southWest.lng + lngSpan * Math.random()) );
333
- m.addTo(L.Rotate._map);
341
+ // m.addTo(L.Rotate._map);
334
342
  L.Rotate.___cluster.addLayer(m);
335
343
  }
336
344
  }
@@ -381,6 +389,7 @@ L.Rotate = {
381
389
  if (this.___bounds) {
382
390
  this.___bounds.remove();
383
391
  }
392
+
384
393
  var padding = document.getElementById('pad_input').valueAsNumber;
385
394
  var latLngBounds = map.getBounds().pad(padding)
386
395
  this.___bounds = L.rectangle(latLngBounds, {
@@ -393,6 +402,35 @@ L.Rotate = {
393
402
  }).addTo(map);
394
403
  },
395
404
 
405
+ /**
406
+ * DEBUG: map.flyToBounds(path.getBounds())
407
+ */
408
+ displayLayersBounds: function() {
409
+ for (const flytopath of ['path', 'polygon', 'circle']) {
410
+ if (!globalThis[flytopath]) {
411
+ continue;
412
+ } else if (this[`___${flytopath}bounds`]) {
413
+ this[`___${flytopath}bounds`].remove();
414
+ }
415
+ let layer = globalThis[flytopath];
416
+ let layerBounds = layer.getBounds();
417
+ this[`___${flytopath}bounds`] = L.featureGroup([
418
+ L.rectangle(layerBounds, {
419
+ fill: false,
420
+ lineCap: 'square',
421
+ color: 'yellow',
422
+ dashArray: '5, 10',
423
+ weight: 1,
424
+ opacity: 0.5
425
+ }),
426
+ L.marker(layerBounds.getNorthWest(), { scale: 0.5, rotation: -45 * L.DomUtil.DEG_TO_RAD, rotateWithView: true }).bindTooltip('<b>NW</b>', {direction: 'center'}),
427
+ L.marker(layerBounds.getNorthEast(), { scale: 0.5, rotation: 45 * L.DomUtil.DEG_TO_RAD, rotateWithView: true }).bindTooltip('<b>NE</b>', {direction: 'center'}),
428
+ L.marker(layerBounds.getSouthEast(), { scale: 0.5, rotation: 135 * L.DomUtil.DEG_TO_RAD, rotateWithView: true }).bindTooltip('<b>SE</b>', {direction: 'center'}),
429
+ L.marker(layerBounds.getSouthWest(), { scale: 0.5, rotation: -135 * L.DomUtil.DEG_TO_RAD, rotateWithView: true }).bindTooltip('<b>SW</b>', {direction: 'center'}),
430
+ ]).addTo(map).eachLayer(m => { if (m.getElement && m.getElement()) m.getElement().style.filter = 'hue-rotate(150deg)'; });
431
+ }
432
+ },
433
+
396
434
  /**
397
435
  * @TODO Debug L.Map.getPixelBounds()
398
436
  */
@@ -410,9 +448,9 @@ L.Rotate = {
410
448
  const BR = L.point(rect).add(L.point(rect.width, rect.height))
411
449
  const BL = L.point(rect).add(L.point(0, rect.height));
412
450
 
413
- const topLeft = L.marker( map.containerPointToLatLng(TL), { title: 'Top Left corner', rotation: 135 * L.DomUtil.DEG_TO_RAD } );
414
- const topRight = L.marker( map.containerPointToLatLng(TR), { title: 'Top Right corner', rotation: -135 * L.DomUtil.DEG_TO_RAD } );
415
- const bottomRight = L.marker( map.containerPointToLatLng(BR), { title: 'Bottom Right corner', rotation: -45 * L.DomUtil.DEG_TO_RAD } );
451
+ const topLeft = L.marker( map.containerPointToLatLng(TL), { title: 'Top Left corner', rotation: -45 * L.DomUtil.DEG_TO_RAD } );
452
+ const topRight = L.marker( map.containerPointToLatLng(TR), { title: 'Top Right corner', rotation: 45 * L.DomUtil.DEG_TO_RAD } );
453
+ const bottomRight = L.marker( map.containerPointToLatLng(BR), { title: 'Bottom Right corner', rotation: 135 * L.DomUtil.DEG_TO_RAD } );
416
454
  const bottomLeft = L.marker( map.containerPointToLatLng(BL), { title: 'Bottom Left corner', rotation: -135 * L.DomUtil.DEG_TO_RAD } );
417
455
 
418
456
  this.___corners = L.featureGroup([topLeft, topRight, bottomRight, bottomLeft]).addTo(map).eachLayer(marker => marker.getElement().style.filter = 'hue-rotate(150deg)');
package/lib/debug.min.js CHANGED
@@ -1 +1 @@
1
- L.Rotate={debug:function(map,options={}){this._map=map,document.head.insertAdjacentHTML("beforeend","<style>\n .leaflet-rotate-info {\n width: 100%;\n }\n .leaflet-rotate-info td {\n /* width: 7em; */\n overflow: hidden;\n /* max-width: 7em; */\n text-overflow: ellipsis;\n /* white-space: nowrap; */\n }\n .leaflet-rotate-info td:nth-of-type(3) {\n font-family: Monospace;\n }\n .leaflet-rotate-info th {\n text-align: left;\n }\n div.crosshair {\n position:absolute;\n width:1px;\n height:1px;\n border: 1px solid green;\n z-index: 100;\n left: 50%;\n right: 50%;\n }\n div.pivot {\n position:absolute;\n width:1px;\n height:1px;\n border: 5px solid yellow;\n border-radius: 100%;\n z-index: 1000;\n }\n div.pixelorigin {\n position: absolute;\n width: 1px;\n height: 1px;\n border: 5px solid yellow;\n border-radius: 100%;\n z-index: 1000;\n }\n div.pivot:before {\n left: -1.5em;\n bottom: -2em;\n position: absolute;\n content: 'PIVOT';\n color: yellow;\n }\n div.pixelorigin:before {\n left: -1.75em;\n top: -2em;\n position: absolute;\n content: 'ORIGIN';\n color: yellow;\n }\n div.panebounds.main {\n position:absolute;\n width:800px;\n height:600px;\n border: 1px solid red;\n border-bottom: 1px red dashed;\n border-right: 1px red dashed;\n z-index: 100;\n }\n div.panebounds.rotate {\n position:absolute;\n width:800px;\n height:600px;\n border: 1px solid purple;\n border-bottom: 1px purple dashed;\n border-right: 1px purple dashed;\n z-index: 100;\n }\n div.crosshair.c1 {\n left:calc(50% - 5px);\n top:50%;\n height: 0;\n width: 10px;\n }\n div.crosshair.c2 {\n left:50%;\n top:calc(50% - 5px);\n width: 0;\n height: 10px;\n }\n #rho_input {\n vertical-align: middle;\n }\n .panebounds:before {\n padding: 1ch;\n }\n .panebounds.rotate:before {\n float: right;\n content: 'ROTATED';\n }\n .panebounds.main:before {\n float: left;\n content: 'MAIN';\n }\n </style>"),map._container.insertAdjacentHTML("afterbegin",'<div class="crosshair c1"></div><div class="crosshair c2"></div>'),map._container.insertAdjacentHTML("afterend",'<hr>\n <table class="leaflet-rotate-info">\n <tr>\n <td>\n <button onclick="L.Rotate._map.setBearing(0);" title="map.setBearing(0);"> 0</button>\n <button onclick="L.Rotate._map.setBearing(15);" title="map.setBearing(15);">15</button>\n <button onclick="L.Rotate._map.setBearing(30);" title="map.setBearing(30);">30</button>\n <button onclick="L.Rotate._map.setBearing(45);" title="map.setBearing(45);">45</button>\n <button onclick="L.Rotate._map.setBearing(60);" title="map.setBearing(60);">60</button>\n <button onclick="L.Rotate._map.setBearing(75);" title="map.setBearing(75);">75</button>\n <button onclick="L.Rotate._map.setBearing(90);" title="map.setBearing(90);">90</button>\n <button onclick="L.Rotate._map.setBearing(180);" title="map.setBearing(180);">180</button>\n </td>\n <td>\n <input title="increase/decrease rotation angle" type="range" min="0" max="360" step="1" value="0" name="rho" id=\'rho_input\' /><span id=\'rho\'></span>\n </td>\n <td>\n <input title="increase/decrease padding bounds" type="range" min="-0.25" max="0" value="0" step="0.01" name="pad" id=\'pad_input\' />\n </td>\n <td>\n <button onclick="L.Rotate.randomRotateMarkers(L.Rotate._map);" title="markers.setRotation(Math.random() * Math.PI / 30 + 0.1)">Rotate Markers</button>\n <button onclick="L.Rotate.randomMarkers(L.Rotate._map, 100);" title="add 100 random markers to map">Add Markers</button>\n </td>\n </tr>\n <tr>\n <th>LatLng </th>\n <td id=\'llx\'></td>\n <td id=\'lly\'></td>\n <td class=\'long\'>LatLng of mouse pointer</td>\n </tr>\n <tr>\n <th>Rel to pane </th>\n <td id=\'lyx\'></td>\n <td id=\'lyy\'></td>\n <td class=\'long\'>Mouse pointer pixel coords relative to _rotatePane</td>\n </tr>\n <tr>\n <th>Rel to container</th>\n <td id=\'cnx\'></td>\n <td id=\'cny\'></td>\n <td class=\'long\'>Mouse pointer coords relative to map &lt;div&gt;</td>\n </tr>\n <tr>\n <th>Pivot </th>\n <td id=\'pvx\'></td>\n <td id=\'pvy\'></td>\n <td class=\'long\'>Last _rotationPane pivot pixel coords relative to _rotationPane</td>\n </tr>\n <tr>\n <th>Pane offset </th>\n <td id=\'pox\'></td>\n <td id=\'poy\'></td>\n <td class=\'long\'>Pixel offset of _mapPane</td>\n </tr>\n <tr>\n <th>Pixel origin </th>\n <td id=\'ogx\'></td>\n <td id=\'ogy\'></td>\n <td class=\'long\'>Negative pixel coords of the (0,0) CRS point relative to _rotatePane</td>\n </tr>\n <tr>\n <th>Pixel bounds </th>\n <td id=\'ogbx\'></td>\n <td id=\'ogby\'></td>\n <td class=\'long\'>Bounds of the current map view in projected pixel coordinates {min, max}.</td>\n </tr>\n </table>'),map.___rotatePixelOrigin=L.DomUtil.create("div","pixelorigin",map._rotatePane),map.___rotatePivotDot=L.DomUtil.create("div","pivot",map._mapPane),L.DomUtil.create("div","panebounds rotate",map._rotatePane),L.DomUtil.create("div","panebounds main",map._mapPane);var rhoInput=document.getElementById("rho_input"),padInput=document.getElementById("pad_input");rhoInput.addEventListener("change",L.Rotate.rotate.bind(this)),rhoInput.addEventListener("mousemove",L.Rotate.rotate.bind(this)),padInput.addEventListener("change",L.Rotate.displayCenter.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayCenter.bind(this)),padInput.addEventListener("change",L.Rotate.displayBounds.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayBounds.bind(this)),padInput.addEventListener("change",L.Rotate.displayPixelBounds.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayPixelBounds.bind(this)),map.on("move rotate zoomend",this.updatePanePos),map.on("rotate zoomend load",this.updatePixelOrigin),map.on("rotate",this.updateRhoInput),map.on("rotate",this.updatePivotDot),map.on("moveend zoomend resetview rotate",this.displayCenter.bind(this)),map.on("moveend zoomend resetview rotate",this.displayBounds.bind(this)),map.on("moveend zoomend resetview rotate",this.displayPixelBounds.bind(this)),this.updatePixelOrigin.call(map),this.updateRhoInput.call(map),this.updatePivotDot.call(map),this.displayCenter.call(this),this.displayBounds.call(this),this.displayPixelBounds.call(this),L.Browser.mobile&&map.compassBearing.enable(),map.on("mousemove",this.logMouse),map.on("locationfound",this.resetHeading),options.log&&map.on("click movestart move moveend zoomstart zoomend locationfound locationerror locationfound",this.logEvent)},logEvent:function(e){console.log(e,e.type)},logMouse:function(e){document.getElementById("llx").innerHTML=e.latlng.lng,document.getElementById("lly").innerHTML=e.latlng.lat,document.getElementById("lyx").innerHTML=e.layerPoint.x,document.getElementById("lyy").innerHTML=e.layerPoint.y,document.getElementById("cnx").innerHTML=e.containerPoint.x,document.getElementById("cny").innerHTML=e.containerPoint.y},rotate:function(e){return 0!==e.buttons&&this._map.setBearing(e.target.valueAsNumber)},updatePixelOrigin:function(){document.getElementById("ogx").innerHTML=this._pixelOrigin.x,document.getElementById("ogy").innerHTML=this._pixelOrigin.y,this.___rotatePixelOrigin.style.left=-this._pixelOrigin.x-1+"px",this.___rotatePixelOrigin.style.top=-this._pixelOrigin.y-1+"px"},updatePivotDot:function(){document.getElementById("pvx").innerHTML=this._pivot.x,document.getElementById("pvy").innerHTML=this._pivot.y,this.___rotatePivotDot.style.left=this._pivot.x-1+"px",this.___rotatePivotDot.style.top=this._pivot.y-1+"px"},updatePanePos:function(){var panePos=this._getMapPanePos();document.getElementById("pox").innerHTML=panePos.x,document.getElementById("poy").innerHTML=panePos.y},updateRhoInput:function(){document.getElementById("rho_input").value=this.getBearing()},rotateOneDegree:function(){var angle=document.getElementById("rho_input").valueAsNumber++;this.setBearing(angle<360?angle:0)},randomRotateMarkers:function(map){var markers=[],steps=[];for(var i in map._layers)map._layers[i]instanceof L.Marker&&(markers.push(map._layers[i]),steps.push(Math.random()*Math.PI/30+.1));function stepOn(steps_left){for(var i=0;i<markers.length;i++)markers[i].setRotation(markers[i].options.rotation+steps[i]);--steps_left&&setTimeout(stepOn.bind(null,steps_left),20)}stepOn(25)},randomMarkers:function(map,number){var map=this._map,populate=function(){for(var i=0;i<number;i++){var bounds=map.getBounds(),southWest=bounds.getSouthWest(),northEast=bounds.getNorthEast(),lngSpan=northEast.lng-southWest.lng,latSpan=northEast.lat-southWest.lat,m=L.marker(L.latLng(southWest.lat+latSpan*Math.random(),southWest.lng+lngSpan*Math.random()));m.addTo(L.Rotate._map),L.Rotate.___cluster.addLayer(m)}};this.___cluster?"function"==typeof L.markerClusterGroup&&populate():this.___cluster=import("https://unpkg.com/leaflet.markercluster@1.4.1/src/index.js").then(m=>{document.head.insertAdjacentHTML("beforeend",'\n \x3c!-- Leaflet-MarkerCluster --\x3e\n <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css">\n <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css">\n '),Object.assign(globalThis.L,m),this.___cluster=L.markerClusterGroup({spiderfyOnMaxZoom:!1,showCoverageOnHover:!1,zoomToBoundsOnClick:!1}).on("clusterclick",a=>a.layer.spiderfy()).addTo(map),populate()})},displayCenter:function(){var map=this._map;this.___centerMarker&&this.___centerMarker.remove(),this.___centerMarker=L.circleMarker(map.getCenter(),{radius:3,color:"red"}).addTo(map).bindTooltip("<b>center</b>",{direction:"right",permanent:!0}),this.___centerMarker.getTooltip().getElement().setAttribute("tabindex","-1")},displayBounds:function(){var map=this._map;this.___bounds&&this.___bounds.remove();var padding=document.getElementById("pad_input").valueAsNumber,latLngBounds=map.getBounds().pad(padding);this.___bounds=L.rectangle(latLngBounds,{fill:!1,lineCap:"square",color:"yellow",dashArray:"5, 10",weight:2}).addTo(map)},displayPixelBounds:function(){var map=this._map;this.___corners&&this.___corners.remove(),this.___pixelbounds&&this.___pixelbounds.remove();const size=map.getSize(),rect=map._container.getBoundingClientRect(),pixelBounds=map.getPixelBounds(),TL=L.point(rect),TR=L.point(rect).add(L.point(rect.width,0)),BR=L.point(rect).add(L.point(rect.width,rect.height)),BL=L.point(rect).add(L.point(0,rect.height)),topLeft=L.marker(map.containerPointToLatLng(TL),{title:"Top Left corner",rotation:135*L.DomUtil.DEG_TO_RAD}),topRight=L.marker(map.containerPointToLatLng(TR),{title:"Top Right corner",rotation:-135*L.DomUtil.DEG_TO_RAD}),bottomRight=L.marker(map.containerPointToLatLng(BR),{title:"Bottom Right corner",rotation:-45*L.DomUtil.DEG_TO_RAD}),bottomLeft=L.marker(map.containerPointToLatLng(BL),{title:"Bottom Left corner",rotation:-135*L.DomUtil.DEG_TO_RAD});this.___corners=L.featureGroup([topLeft,topRight,bottomRight,bottomLeft]).addTo(map).eachLayer(marker=>marker.getElement().style.filter="hue-rotate(150deg)"),document.getElementById("ogbx").innerHTML=JSON.stringify(pixelBounds.min),document.getElementById("ogby").innerHTML=JSON.stringify(pixelBounds.max)},resetHeading:function(e){null!==e.heading&&this.setBearing(e.heading)},locate:function(){this._map.locate({setView:!0,enableHighAccuracy:!0})}};
1
+ L.Rotate={debug:function(map,options={}){this._map=map,document.head.insertAdjacentHTML("beforeend","<style>\n .leaflet-rotate-info {\n width: 100%;\n }\n .leaflet-rotate-info td {\n /* width: 7em; */\n overflow: hidden;\n /* max-width: 7em; */\n text-overflow: ellipsis;\n /* white-space: nowrap; */\n }\n .leaflet-rotate-info td:nth-of-type(3) {\n font-family: Monospace;\n }\n .leaflet-rotate-info th {\n text-align: left;\n }\n div.crosshair {\n position:absolute;\n width:1px;\n height:1px;\n border: 1px solid green;\n z-index: 100;\n left: 50%;\n right: 50%;\n }\n div.pivot {\n position:absolute;\n width:1px;\n height:1px;\n border: 5px solid yellow;\n border-radius: 100%;\n z-index: 1000;\n }\n div.pixelorigin {\n position: absolute;\n width: 1px;\n height: 1px;\n border: 5px solid yellow;\n border-radius: 100%;\n z-index: 1000;\n }\n div.pivot:before {\n left: -1.5em;\n bottom: -2em;\n position: absolute;\n content: 'PIVOT';\n color: yellow;\n }\n div.pixelorigin:before {\n left: -1.75em;\n top: -2em;\n position: absolute;\n content: 'ORIGIN';\n color: yellow;\n }\n div.panebounds.main {\n position:absolute;\n width:800px;\n height:600px;\n border: 1px solid red;\n border-bottom: 1px red dashed;\n border-right: 1px red dashed;\n z-index: 100;\n }\n div.panebounds.rotate {\n position:absolute;\n width:800px;\n height:600px;\n border: 1px solid purple;\n border-bottom: 1px purple dashed;\n border-right: 1px purple dashed;\n z-index: 100;\n }\n div.crosshair.c1 {\n left:calc(50% - 5px);\n top:50%;\n height: 0;\n width: 10px;\n }\n div.crosshair.c2 {\n left:50%;\n top:calc(50% - 5px);\n width: 0;\n height: 10px;\n }\n #rho_input {\n vertical-align: middle;\n }\n .panebounds:before {\n padding: 1ch;\n }\n .panebounds.rotate:before {\n float: right;\n content: 'ROTATED';\n }\n .panebounds.main:before {\n float: left;\n content: 'MAIN';\n }\n </style>"),map._container.insertAdjacentHTML("afterbegin",'<div class="crosshair c1"></div><div class="crosshair c2"></div>'),map._container.insertAdjacentHTML("afterend",'<hr>\n <table class="leaflet-rotate-info">\n <tr>\n <td>\n <button onclick="L.Rotate._map.setBearing(0);" title="map.setBearing(0);"> 0</button>\n <button onclick="L.Rotate._map.setBearing(15);" title="map.setBearing(15);">15</button>\n <button onclick="L.Rotate._map.setBearing(30);" title="map.setBearing(30);">30</button>\n <button onclick="L.Rotate._map.setBearing(45);" title="map.setBearing(45);">45</button>\n <button onclick="L.Rotate._map.setBearing(60);" title="map.setBearing(60);">60</button>\n <button onclick="L.Rotate._map.setBearing(75);" title="map.setBearing(75);">75</button>\n <button onclick="L.Rotate._map.setBearing(90);" title="map.setBearing(90);">90</button>\n <button onclick="L.Rotate._map.setBearing(180);" title="map.setBearing(180);">180</button>\n </td>\n <td>\n <input title="increase/decrease rotation angle" type="range" min="0" max="360" step="1" value="0" name="rho" id=\'rho_input\' /><span id=\'rho\'></span>\n </td>\n <td>\n <input title="increase/decrease padding bounds" type="range" min="-0.25" max="0" value="0" step="0.01" name="pad" id=\'pad_input\' />\n </td>\n <td>\n <button onclick="L.Rotate.randomRotateMarkers(L.Rotate._map);" title="markers.setRotation(Math.random() * Math.PI / 30 + 0.1)">Rotate Markers</button>\n <button onclick="L.Rotate.randomMarkers(L.Rotate._map, 100);" title="add 100 random markers to map">Add Markers</button>\n </td>\n </tr>\n <tr>\n <th>LatLng </th>\n <td id=\'llx\'></td>\n <td id=\'lly\'></td>\n <td class=\'long\'>LatLng of mouse pointer</td>\n </tr>\n <tr>\n <th>Rel to pane </th>\n <td id=\'lyx\'></td>\n <td id=\'lyy\'></td>\n <td class=\'long\'>Mouse pointer pixel coords relative to _rotatePane</td>\n </tr>\n <tr>\n <th>Rel to container</th>\n <td id=\'cnx\'></td>\n <td id=\'cny\'></td>\n <td class=\'long\'>Mouse pointer coords relative to map &lt;div&gt;</td>\n </tr>\n <tr>\n <th>Pivot </th>\n <td id=\'pvx\'></td>\n <td id=\'pvy\'></td>\n <td class=\'long\'>Last _rotationPane pivot pixel coords relative to _rotationPane</td>\n </tr>\n <tr>\n <th>Pane offset </th>\n <td id=\'pox\'></td>\n <td id=\'poy\'></td>\n <td class=\'long\'>Pixel offset of _mapPane</td>\n </tr>\n <tr>\n <th>Pixel origin </th>\n <td id=\'ogx\'></td>\n <td id=\'ogy\'></td>\n <td class=\'long\'>Negative pixel coords of the (0,0) CRS point relative to _rotatePane</td>\n </tr>\n <tr>\n <th>Pixel bounds </th>\n <td id=\'ogbx\'></td>\n <td id=\'ogby\'></td>\n <td class=\'long\'>Bounds of the current map view in projected pixel coordinates {min, max}.</td>\n </tr>\n </table>'),map.___rotatePixelOrigin=L.DomUtil.create("div","pixelorigin",map._rotatePane),map.___rotatePivotDot=L.DomUtil.create("div","pivot",map._mapPane),L.DomUtil.create("div","panebounds rotate",map._rotatePane),L.DomUtil.create("div","panebounds main",map._mapPane);var rhoInput=document.getElementById("rho_input"),padInput=document.getElementById("pad_input");rhoInput.addEventListener("change",L.Rotate.rotate.bind(this)),rhoInput.addEventListener("mousemove",L.Rotate.rotate.bind(this)),padInput.addEventListener("change",L.Rotate.displayCenter.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayCenter.bind(this)),padInput.addEventListener("change",L.Rotate.displayBounds.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayBounds.bind(this)),padInput.addEventListener("change",L.Rotate.displayLayersBounds.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayLayersBounds.bind(this)),padInput.addEventListener("change",L.Rotate.displayPixelBounds.bind(this)),padInput.addEventListener("mousemove",L.Rotate.displayPixelBounds.bind(this)),map.on("move rotate zoomend",this.updatePanePos),map.on("rotate zoomend load",this.updatePixelOrigin),map.on("rotate",this.updateRhoInput),map.on("rotate",this.updatePivotDot),map.on("moveend zoomend resetview rotate",this.displayCenter.bind(this)),map.on("moveend zoomend resetview rotate",this.displayBounds.bind(this)),map.on("moveend zoomend resetview rotate",this.displayLayersBounds.bind(this)),map.on("moveend zoomend resetview rotate",this.displayPixelBounds.bind(this)),this.updatePixelOrigin.call(map),this.updateRhoInput.call(map),this.updatePivotDot.call(map),this.displayCenter.call(this),this.displayBounds.call(this),this.displayLayersBounds.call(this),this.displayPixelBounds.call(this),L.Browser.mobile&&map.compassBearing.enable(),map.on("mousemove",this.logMouse),map.on("locationfound",this.resetHeading),options.log&&map.on("click movestart move moveend zoomstart zoomend locationfound locationerror locationfound",this.logEvent)},logEvent:function(e){console.log(e,e.type)},logMouse:function(e){document.getElementById("llx").innerHTML=e.latlng.lng,document.getElementById("lly").innerHTML=e.latlng.lat,document.getElementById("lyx").innerHTML=e.layerPoint.x,document.getElementById("lyy").innerHTML=e.layerPoint.y,document.getElementById("cnx").innerHTML=e.containerPoint.x,document.getElementById("cny").innerHTML=e.containerPoint.y},rotate:function(e){return 0!==e.buttons&&this._map.setBearing(e.target.valueAsNumber)},updatePixelOrigin:function(){this._pixelOrigin&&(document.getElementById("ogx").innerHTML=this._pixelOrigin.x,document.getElementById("ogy").innerHTML=this._pixelOrigin.y,this.___rotatePixelOrigin.style.left=-this._pixelOrigin.x-1+"px",this.___rotatePixelOrigin.style.top=-this._pixelOrigin.y-1+"px")},updatePivotDot:function(){this._pivot&&(document.getElementById("pvx").innerHTML=this._pivot.x,document.getElementById("pvy").innerHTML=this._pivot.y,this.___rotatePivotDot.style.left=this._pivot.x-1+"px",this.___rotatePivotDot.style.top=this._pivot.y-1+"px")},updatePanePos:function(){var panePos=this._getMapPanePos();document.getElementById("pox").innerHTML=panePos.x,document.getElementById("poy").innerHTML=panePos.y},updateRhoInput:function(){document.getElementById("rho_input").value=this.getBearing()},rotateOneDegree:function(){var angle=document.getElementById("rho_input").valueAsNumber++;this.setBearing(angle<360?angle:0)},randomRotateMarkers:function(map){var markers=[],steps=[];for(var i in map._layers)map._layers[i]instanceof L.Marker&&(markers.push(map._layers[i]),steps.push(Math.random()*Math.PI/30+.1));function stepOn(steps_left){for(var i=0;i<markers.length;i++)markers[i].setRotation(markers[i].options.rotation+steps[i]);--steps_left&&setTimeout(stepOn.bind(null,steps_left),20)}stepOn(25)},randomMarkers:function(map,number){var map=this._map,populate=function(){for(var i=0;i<number;i++){var bounds=map.getBounds(),southWest=bounds.getSouthWest(),northEast=bounds.getNorthEast(),lngSpan=northEast.lng-southWest.lng,latSpan=northEast.lat-southWest.lat,m=L.marker(L.latLng(southWest.lat+latSpan*Math.random(),southWest.lng+lngSpan*Math.random()));L.Rotate.___cluster.addLayer(m)}};this.___cluster?"function"==typeof L.markerClusterGroup&&populate():this.___cluster=import("https://unpkg.com/leaflet.markercluster@1.4.1/src/index.js").then(m=>{document.head.insertAdjacentHTML("beforeend",'\n \x3c!-- Leaflet-MarkerCluster --\x3e\n <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css">\n <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css">\n '),Object.assign(globalThis.L,m),this.___cluster=L.markerClusterGroup({spiderfyOnMaxZoom:!1,showCoverageOnHover:!1,zoomToBoundsOnClick:!1}).on("clusterclick",a=>a.layer.spiderfy()).addTo(map),populate()})},displayCenter:function(){var map=this._map;this.___centerMarker&&this.___centerMarker.remove(),this.___centerMarker=L.circleMarker(map.getCenter(),{radius:3,color:"red"}).addTo(map).bindTooltip("<b>center</b>",{direction:"right",permanent:!0}),this.___centerMarker.getTooltip().getElement().setAttribute("tabindex","-1")},displayBounds:function(){var map=this._map;this.___bounds&&this.___bounds.remove();var padding=document.getElementById("pad_input").valueAsNumber,latLngBounds=map.getBounds().pad(padding);this.___bounds=L.rectangle(latLngBounds,{fill:!1,lineCap:"square",color:"yellow",dashArray:"5, 10",weight:2}).addTo(map)},displayLayersBounds:function(){for(const flytopath of["path","polygon","circle"]){if(!globalThis[flytopath])continue;this[`___${flytopath}bounds`]&&this[`___${flytopath}bounds`].remove();let layer,layerBounds=globalThis[flytopath].getBounds();this[`___${flytopath}bounds`]=L.featureGroup([L.rectangle(layerBounds,{fill:!1,lineCap:"square",color:"yellow",dashArray:"5, 10",weight:1,opacity:.5}),L.marker(layerBounds.getNorthWest(),{scale:.5,rotation:-45*L.DomUtil.DEG_TO_RAD,rotateWithView:!0}).bindTooltip("<b>NW</b>",{direction:"center"}),L.marker(layerBounds.getNorthEast(),{scale:.5,rotation:45*L.DomUtil.DEG_TO_RAD,rotateWithView:!0}).bindTooltip("<b>NE</b>",{direction:"center"}),L.marker(layerBounds.getSouthEast(),{scale:.5,rotation:135*L.DomUtil.DEG_TO_RAD,rotateWithView:!0}).bindTooltip("<b>SE</b>",{direction:"center"}),L.marker(layerBounds.getSouthWest(),{scale:.5,rotation:-135*L.DomUtil.DEG_TO_RAD,rotateWithView:!0}).bindTooltip("<b>SW</b>",{direction:"center"})]).addTo(map).eachLayer(m=>{m.getElement&&m.getElement()&&(m.getElement().style.filter="hue-rotate(150deg)")})}},displayPixelBounds:function(){var map=this._map;this.___corners&&this.___corners.remove(),this.___pixelbounds&&this.___pixelbounds.remove();const size=map.getSize(),rect=map._container.getBoundingClientRect(),pixelBounds=map.getPixelBounds(),TL=L.point(rect),TR=L.point(rect).add(L.point(rect.width,0)),BR=L.point(rect).add(L.point(rect.width,rect.height)),BL=L.point(rect).add(L.point(0,rect.height)),topLeft=L.marker(map.containerPointToLatLng(TL),{title:"Top Left corner",rotation:-45*L.DomUtil.DEG_TO_RAD}),topRight=L.marker(map.containerPointToLatLng(TR),{title:"Top Right corner",rotation:45*L.DomUtil.DEG_TO_RAD}),bottomRight=L.marker(map.containerPointToLatLng(BR),{title:"Bottom Right corner",rotation:135*L.DomUtil.DEG_TO_RAD}),bottomLeft=L.marker(map.containerPointToLatLng(BL),{title:"Bottom Left corner",rotation:-135*L.DomUtil.DEG_TO_RAD});this.___corners=L.featureGroup([topLeft,topRight,bottomRight,bottomLeft]).addTo(map).eachLayer(marker=>marker.getElement().style.filter="hue-rotate(150deg)"),document.getElementById("ogbx").innerHTML=JSON.stringify(pixelBounds.min),document.getElementById("ogby").innerHTML=JSON.stringify(pixelBounds.max)},resetHeading:function(e){null!==e.heading&&this.setBearing(e.heading)},locate:function(){this._map.locate({setView:!0,enableHighAccuracy:!0})}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leaflet-rotate",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A Leaflet plugin that allows to add rotation functionality to map tiles",
5
5
  "type": "module",
6
6
  "main": "dist/leaflet-rotate.js",
@@ -8,12 +8,24 @@ const domUtilProto = L.extend({}, L.DomUtil);
8
8
 
9
9
  L.extend(L.DomUtil, {
10
10
 
11
+ /**
12
+ * Resets the 3D CSS transform of `el` so it is
13
+ * translated by `offset` pixels and optionally
14
+ * scaled by `scale`. Does not have an effect if
15
+ * the browser doesn't support 3D CSS transforms.
16
+ *
17
+ * @param {HTMLElement} el
18
+ * @param {L.Point} offset
19
+ * @param {Number} scale
20
+ * @param {Number} bearing
21
+ * @param {L.Point} pivot
22
+ */
11
23
  setTransform: function(el, offset, scale, bearing, pivot) {
12
24
  var pos = offset || new L.Point(0, 0);
13
25
 
14
26
  if (!bearing) {
15
27
  offset = pos._round();
16
- return domUtilProto.setTransform.call(this, el, offset, scale);
28
+ return domUtilProto.setTransform.apply(this, arguments);
17
29
  }
18
30
 
19
31
  pos = pos.rotateFrom(bearing, pivot);
@@ -24,9 +36,21 @@ L.extend(L.DomUtil, {
24
36
  ' rotate(' + bearing + 'rad)';
25
37
  },
26
38
 
27
- setPosition: function(el, point, bearing, pivot) { // (HTMLElement, Point[, Boolean])
39
+ /**
40
+ * Sets the position of `el` to coordinates specified by
41
+ * `position`, using CSS translate or top/left positioning
42
+ * depending on the browser (used by Leaflet internally
43
+ * to position its layers).
44
+ *
45
+ * @param {HTMLElement} el
46
+ * @param {L.Point} point
47
+ * @param {Number} bearing
48
+ * @param {L.Point} pivot
49
+ * @param {Number} scale
50
+ */
51
+ setPosition: function(el, point, bearing, pivot, scale) {
28
52
  if (!bearing) {
29
- return domUtilProto.setPosition.call(this, el, point);
53
+ return domUtilProto.setPosition.apply(this, arguments);
30
54
  }
31
55
 
32
56
  /*eslint-disable */
@@ -34,15 +58,21 @@ L.extend(L.DomUtil, {
34
58
  /*eslint-enable */
35
59
 
36
60
  if (L.Browser.any3d) {
37
- L.DomUtil.setTransform(el, point, undefined, bearing, pivot);
61
+ L.DomUtil.setTransform(el, point, scale, bearing, pivot);
38
62
  } else {
39
63
  el.style.left = point.x + 'px';
40
64
  el.style.top = point.y + 'px';
41
65
  }
42
66
  },
43
67
 
44
- // Constants for rotation
68
+ /**
69
+ * @constant radians = degrees × π/180°
70
+ */
45
71
  DEG_TO_RAD: Math.PI / 180,
72
+
73
+ /**
74
+ * @constant degrees = radians × 180°/π
75
+ */
46
76
  RAD_TO_DEG: 180 / Math.PI,
47
77
 
48
78
  });
@@ -4,8 +4,15 @@
4
4
  * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/dom/Draggable.js
5
5
  */
6
6
 
7
+ /**
8
+ * A class for making DOM elements draggable (including touch support).
9
+ * Used internally for map and marker dragging. Only works for elements
10
+ * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition).
11
+ */
12
+
7
13
  L.Draggable.include({
8
14
 
15
+ /** @TODO */
9
16
  // updateMapBearing: function(mapBearing) {
10
17
  // this._mapBearing = mapBearing;
11
18
  // },
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @external L.LatLngBounds
3
+ *
4
+ * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/geo/LatLngBounds.js
5
+ */
6
+
7
+ /**
8
+ * @TODO find out if should override here some functions in order
9
+ * to always get correct { _southWest, _northEast } bounds on a rotaded
10
+ * map, for example: at 180° "_southWest" should becomes "_northEast"?
11
+ *
12
+ * @see L.Map.getBounds()
13
+ */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @external L.Bounds
3
+ *
4
+ * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/geometry/Bounds.js
5
+ */
6
+
7
+ /**
8
+ * @TODO find out if should override here some functions in order
9
+ * to always get correct { min, max } pixel bounds on a rotaded
10
+ * map, for example: at 180° "min" should becomes "max"?
11
+ *
12
+ * @see L.Map.getPixelBounds()
13
+ */
@@ -26,6 +26,11 @@ L.extend(L.Point.prototype, {
26
26
  * 3. add (pivot.x, pivot.y) back
27
27
  *
28
28
  * same as `this.subtract(pivot).rotate(theta).add(pivot)`
29
+ *
30
+ * @param {Number} theta
31
+ * @param {L.Point} pivot
32
+ *
33
+ * @returns {L.Point}
29
34
  */
30
35
  rotateFrom: function(theta, pivot) {
31
36
  if (!theta) { return this; }
package/src/index.js CHANGED
@@ -1,7 +1,21 @@
1
1
  /**
2
+ * Export Leaflet classes in the same order as the core library
3
+ *
2
4
  * @external L
3
5
  *
4
6
  * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/Leaflet.js
7
+ *
8
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/control/index.js
9
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/core/index.js
10
+ *
11
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/dom/index.js
12
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/geometry/index.js
13
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/geo/index.js
14
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/index.js
15
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/marker/index.js
16
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/tile/index.js
17
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/vector/index.js
18
+ * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/map/index.js
5
19
  */
6
20
 
7
21
  // import {version} from '../package.json';
@@ -19,9 +33,10 @@ export * from './dom/Draggable';
19
33
 
20
34
  // geometry
21
35
  export * from './geometry/Point';
36
+ export * from './geometry/Bounds';
22
37
 
23
38
  // geo
24
- // export * from './geo/index';
39
+ export * from './geo/LatLngBounds';
25
40
 
26
41
  // layer
27
42
  export * from './layer/DivOverlay';
@@ -30,9 +45,7 @@ export * from './layer/Tooltip';
30
45
  export * from './layer/marker/Icon';
31
46
  export * from './layer/marker/Marker';
32
47
  export * from './layer/tile/GridLayer';
33
- export * from './layer/vector/Canvas';
34
48
  export * from './layer/vector/Renderer';
35
- export * from './layer/vector/SVG';
36
49
 
37
50
  // map
38
51
  export * from './map/Map';
@@ -8,16 +8,23 @@ const divOverlayProto = L.extend({}, L.DivOverlay.prototype);
8
8
 
9
9
  L.DivOverlay.include({
10
10
 
11
+ /**
12
+ * Update L.Popup and L.Tooltip anchor positions after
13
+ * the map is moved by calling `map.setBearing(theta)`
14
+ *
15
+ * @listens L.Map~rotate
16
+ */
11
17
  getEvents: function() {
12
- return L.extend(divOverlayProto.getEvents.call(this), { rotate: this._updatePosition });
18
+ return L.extend(divOverlayProto.getEvents.apply(this, arguments), { rotate: this._updatePosition });
13
19
  },
14
20
 
21
+ /**
22
+ * 0. update element anchor point (divOverlayProto v1.9.3)
23
+ * 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
24
+ */
15
25
  _updatePosition: function() {
16
- // 0. update anchor (leaflet v1.9.3)
17
- divOverlayProto._updatePosition.call(this);
18
- // 1. subtract anchor
19
- // 2. rotate element
20
- // 3. restore anchor
26
+ if (!this._map) { return; }
27
+ divOverlayProto._updatePosition.apply(this, arguments);
21
28
  if (this._map && this._map._rotate && this._zoomAnimated) {
22
29
  var anchor = this._getAnchor();
23
30
  var pos = L.DomUtil.getPosition(this._container).subtract(anchor);
@@ -8,12 +8,12 @@ const popupProto = L.extend({}, L.Popup.prototype);
8
8
 
9
9
  L.Popup.include({
10
10
 
11
+ /**
12
+ * 0. update element anchor point (popupProto v1.9.3)
13
+ * 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
14
+ */
11
15
  _animateZoom: function(e) {
12
- // 0. update anchor (leaflet v1.9.3)
13
- popupProto._animateZoom.call(this, e);
14
- // 1. subtract anchor
15
- // 2. rotate element
16
- // 3. restore anchor
16
+ popupProto._animateZoom.apply(this, arguments);
17
17
  if (this._map && this._map._rotate) {
18
18
  var anchor = this._getAnchor();
19
19
  var pos = L.DomUtil.getPosition(this._container).subtract(anchor);
@@ -22,7 +22,7 @@ L.Popup.include({
22
22
  },
23
23
 
24
24
  /**
25
- * Hot fix for L.Popup.mergeOptions({ keepInView: true, });
25
+ * Fix for L.popup({ keepInView = true })
26
26
  *
27
27
  * @see https://github.com/fnicollet/Leaflet/pull/21
28
28
  */
@@ -44,8 +44,8 @@ L.Popup.include({
44
44
 
45
45
  layerPos._add(L.DomUtil.getPosition(this._container));
46
46
 
47
- // var containerPos = map.layerPointToContainerPoint(layerPos);
48
47
  /** @TODO use popupProto._adjustPan */
48
+ // var containerPos = map.layerPointToContainerPoint(layerPos);
49
49
  var containerPos = layerPos._add(this._map._getMapPanePos()),
50
50
  padding = L.point(this.options.autoPanPadding),
51
51
  paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),
@@ -10,7 +10,7 @@ L.Tooltip.include({
10
10
 
11
11
  _animateZoom: function(e) {
12
12
  if (!this._map._rotate) {
13
- return tooltipProto._animateZoom.call(this, e);
13
+ return tooltipProto._animateZoom.apply(this, arguments);
14
14
  }
15
15
  var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
16
16
 
@@ -20,7 +20,7 @@ L.Tooltip.include({
20
20
 
21
21
  _updatePosition: function() {
22
22
  if (!this._map._rotate) {
23
- return tooltipProto._updatePosition.call(this);
23
+ return tooltipProto._updatePosition.apply(this, arguments);
24
24
  }
25
25
  var pos = this._map.latLngToLayerPoint(this._latlng);
26
26
 
@@ -3,20 +3,35 @@
3
3
  * @external L.Handler.MarkerDrag
4
4
  *
5
5
  * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/marker/Marker.js
6
+ * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/marker/Marker.Drag.js
7
+ * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/dom/Draggable.js
6
8
  */
7
9
 
8
10
  const markerProto = L.extend({}, L.Marker.prototype);
9
11
 
10
12
  L.Marker.mergeOptions({
11
13
 
12
- // @option rotation: Number = 0
13
- // Rotation of this marker in rad
14
+ /**
15
+ * Rotation of this marker in rad
16
+ *
17
+ * @type {Number}
18
+ */
14
19
  rotation: 0,
15
20
 
16
- // @option rotateWithView: Boolean = false
17
- // Rotate this marker when map rotates
21
+ /**
22
+ * Rotate this marker when map rotates
23
+ *
24
+ * @type {Boolean}
25
+ */
18
26
  rotateWithView: false,
19
27
 
28
+ /**
29
+ * Scale of the marker icon
30
+ *
31
+ * @type {Number}
32
+ */
33
+ scale: undefined,
34
+
20
35
  });
21
36
 
22
37
  var markerDragProto; // retrived at runtime (see below: L.Marker::_initInteraction())
@@ -25,7 +40,7 @@ var MarkerDrag = {
25
40
 
26
41
  // _onDragStart: function() {
27
42
  // if (!this._marker._map._rotate) {
28
- // return markerDragProto._onDragStart.call(this)
43
+ // return markerDragProto._onDragStart.apply(this, arguments);
29
44
  // }
30
45
  // this._draggable.updateMapBearing(this._marker._map._bearing);
31
46
  // },
@@ -68,24 +83,25 @@ var MarkerDrag = {
68
83
  if (this._marker._map._rotate) {
69
84
  this._marker.update();
70
85
  }
71
- markerDragProto._onDragEnd.call(this, e);
86
+ markerDragProto._onDragEnd.apply(this, arguments);
72
87
  },
73
88
 
74
89
  };
75
90
 
76
91
  L.Marker.include({
77
92
 
93
+ /**
94
+ * Update L.Marker anchor position after the map
95
+ * is moved by calling `map.setBearing(theta)`
96
+ *
97
+ * @listens L.Map~rotate
98
+ */
78
99
  getEvents: function() {
79
- return L.extend(markerProto.getEvents.call(this), { rotate: this.update });
80
- },
81
-
82
- onAdd: function(map) {
83
- markerProto.onAdd.call(this, map);
84
- map.on('rotate', this.update, this);
100
+ return L.extend(markerProto.getEvents.apply(this, arguments), { rotate: this.update });
85
101
  },
86
102
 
87
103
  _initInteraction: function() {
88
- var ret = markerProto._initInteraction.call(this);
104
+ var ret = markerProto._initInteraction.apply(this, arguments);
89
105
  if (this.dragging && this.dragging.enabled() && this._map && this._map._rotate) {
90
106
  // L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable
91
107
  markerDragProto = markerDragProto || Object.getPrototypeOf(this.dragging);
@@ -115,12 +131,12 @@ L.Marker.include({
115
131
 
116
132
  /** @TODO use markerProto._setPos */
117
133
  if (this._icon) {
118
- L.DomUtil.setPosition(this._icon, pos, bearing, pos);
134
+ L.DomUtil.setPosition(this._icon, pos, bearing, pos, this.options.scale);
119
135
  }
120
136
 
121
137
  /** @TODO use markerProto._setPos */
122
138
  if (this._shadow) {
123
- L.DomUtil.setPosition(this._shadow, pos, bearing, pos);
139
+ L.DomUtil.setPosition(this._shadow, pos, bearing, pos, this.options.scale);
124
140
  }
125
141
 
126
142
  this._zIndex = pos.y + this.options.zIndexOffset;
@@ -128,12 +144,12 @@ L.Marker.include({
128
144
  this._resetZIndex();
129
145
  },
130
146
 
131
- _updateZIndex: function(offset) {
132
- if (!this._map._rotate) {
133
- return markerProto._updateZIndex.call(this, offset)
134
- }
135
- this._icon.style.zIndex = Math.round(this._zIndex + offset);
136
- },
147
+ // _updateZIndex: function(offset) {
148
+ // if (!this._map._rotate) {
149
+ // return markerProto._updateZIndex.apply(this, arguments);
150
+ // }
151
+ // this._icon.style.zIndex = Math.round(this._zIndex + offset);
152
+ // },
137
153
 
138
154
  setRotation: function(rotation) {
139
155
  this.options.rotation = rotation;
@@ -8,8 +8,14 @@ const gridLayerProto = L.extend({}, L.GridLayer.prototype);
8
8
 
9
9
  L.GridLayer.include({
10
10
 
11
+ /**
12
+ * Redraw L.TileLayer bounds after the map is
13
+ * moved by just calling `map.setBearing(theta)`
14
+ *
15
+ * @listens L.Map~rotate
16
+ */
11
17
  getEvents: function() {
12
- var events = gridLayerProto.getEvents.call(this);
18
+ var events = gridLayerProto.getEvents.apply(this, arguments);
13
19
  if (this._map._rotate && !this.options.updateWhenIdle) {
14
20
  if (!this._onRotate) {
15
21
  this._onRotate = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);
@@ -21,7 +27,7 @@ L.GridLayer.include({
21
27
 
22
28
  _getTiledPixelBounds: function(center) {
23
29
  if (!this._map._rotate) {
24
- return gridLayerProto._getTiledPixelBounds.call(this, center);
30
+ return gridLayerProto._getTiledPixelBounds.apply(this, arguments);
25
31
  }
26
32
 
27
33
  return this._map._getNewPixelBounds(center, this._tileZoom);
@@ -8,15 +8,15 @@ const rendererProto = L.extend({}, L.Renderer.prototype);
8
8
 
9
9
  L.Renderer.include({
10
10
 
11
- // onAdd: function() {
12
- // rendererProto.onAdd.call(this);
13
- // // this._map.on('rotate', this._update, this);
14
- // },
15
-
16
- // onRemove: function() {
17
- // rendererProto.onRemove.call(this);
18
- // // this._map.off('rotate', this._update, this);
19
- // },
11
+ /**
12
+ * Redraw L.Canvas and L.SVG renderer bounds after the
13
+ * map is moved by just calling `map.setBearing(theta)`
14
+ *
15
+ * @listens L.Map~rotate
16
+ */
17
+ getEvents: function() {
18
+ return L.extend(rendererProto.getEvents.apply(this, arguments), { rotate: this._update });
19
+ },
20
20
 
21
21
  /**
22
22
  * @TODO rechek this changes from leaflet@v1.9.3
@@ -25,7 +25,7 @@ L.Renderer.include({
25
25
  */
26
26
  _updateTransform: function(center, zoom) {
27
27
  if (!this._map._rotate) {
28
- return rendererProto._updateTransform.call(this, center, zoom);
28
+ return rendererProto._updateTransform.apply(this, arguments);
29
29
  }
30
30
  var scale = this._map.getZoomScale(zoom, this._zoom),
31
31
  offset = this._map._latLngToNewLayerPoint(this._topLeft, zoom, center);
@@ -38,7 +38,7 @@ L.Renderer.include({
38
38
 
39
39
  _update: function() {
40
40
  if (!this._map._rotate) {
41
- return rendererProto._update.call(this);
41
+ return rendererProto._update.apply(this, arguments);
42
42
  }
43
43
  // Update pixel bounds of renderer container (for positioning/sizing/clipping later)
44
44
  // Subclasses are responsible of firing the 'update' event.