ppete2 / Leaflet.PolylineMeasure

Leaflet Plugin to measure distances of simple lines as well as of complex polylines
https://ppete2.github.io/Leaflet.PolylineMeasure/
BSD 2-Clause "Simplified" License
214 stars 84 forks source link

Cannot set properties of null (setting '_source') #106

Open VardgesHA777 opened 1 year ago

VardgesHA777 commented 1 year ago

I installed it in my react-leaflet version 4.2.0. I put starting and ending points. When I click one of dots on the map and removing finger from mouse and then click my desired place to be thestart/end poin, my application crashes.

Cannot set properties of null (setting '_source') TypeError: Cannot set properties of null (setting '_source')

import { useEffect } from 'react'; import { useMap } from 'react-leaflet'; import L from 'leaflet';

export default function LeafletRuler() { const map = useMap();

useEffect(() => { if (!map) return; const options = { position: 'topright', // Position to show the control. Values: 'topright', 'topleft', 'bottomright', 'bottomleft' };

setTimeout(() => {
  L.control.polylineMeasure(options).addTo(map);
}, 1000);

}, [map]);

return null; }

const Map = () => { useEffect(() => { const script = document.createElement('script'); script.src = 'https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.js'; document.body.appendChild(script); }, []);

return (

{/* */}

); };

export default Map;

LuigiElleBalotta commented 5 months ago

BUMP! Same problem with angular

Using:

"leaflet": "^1.9.4", "leaflet-bing-layer": "^3.3.1", "leaflet-clonelayer": "^1.0.7", "leaflet-draw": "^1.0.4", "leaflet-measure": "^3.1.0", "leaflet.polylinemeasure": "^3.0.0",

dankarran commented 3 months ago

The same thing happens even if React and Angular are excluded. You can replicate it on the demos as well, though it just gives an error in the console and everything else seems to carry on working.

For me it only happens in Chrome (not Safari), and happens after double clicking the end point and then moving it.