Skip to content

Commit

Permalink
Add workaround for maps with preferCanvas=true
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Oct 26, 2021
1 parent 0fab156 commit 1fa58ab
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/leaflet.measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@
this._trail = {
points: [],
overlays: L.featureGroup(),
canvas: map.options.preferCanvas || false,
};
if ( map.options.preferCanvas ) {
map.options.preferCanvas = false;
console.warn( 'Temporarily reset map.options.prefersCanvas to false' );
//HACK: With canvas rendering enabled (and no other markers present on the map), this will create an permanent
// overlaying layer of type L.Canvas that swallows mouse events.
}
map.addLayer( this._trail.overlays );

L.DomUtil.addClass(map._container, "leaflet-measure-map");
Expand Down Expand Up @@ -395,6 +402,7 @@
_clearOverlay: function () {
this._map.removeLayer(this._trail.overlays);
this._trail.overlays = null;
this._map.options.preferCanvas = this._trail.canvas;
},
toRadians: function (deg) {
return deg * (Math.PI / 180);
Expand Down

0 comments on commit 1fa58ab

Please sign in to comment.