Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
VardgesHA777 opened this issue Aug 8, 2023 · 2 comments
Open

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

VardgesHA777 opened this issue Aug 8, 2023 · 2 comments

Comments

@VardgesHA777
Copy link

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 (

<MapContainer
style={{ height: '100%', width: '100%', zIndex: 1 }}
zoom={10}
maxZoom={22}
center={[40.2, 45.7]}
attributionControl={false}
zoomAnimation={true}
// @ts-ignore
fullscreenControl={true}
crs={CRS.EPSG4326}
>


{/* */}

);
};

export default Map;

@LuigiElleBalotta
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants