Skip to content

Instantly share code, notes, and snippets.

@MrMeison
Created September 1, 2022 06:41
Show Gist options
  • Save MrMeison/d27352ce02afc971014c550974edcf20 to your computer and use it in GitHub Desktop.
Save MrMeison/d27352ce02afc971014c550974edcf20 to your computer and use it in GitHub Desktop.
const Map = (props: PropsMap) => {
...
useEffect(() => {
if (!map) {
return;
}
const layerGroup = new LayerGroup();
points.forEach((point) => {
leaflet
.marker(...).addTo(layerGroup);
});
map.addLayer(layerGroup);
return () => {
layerGroup.remove();
};
}, [map, points]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment