[Bug] Map instance caching has buggy behavior when used with clustering
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia riproducendo il flusso di navigazione descritto con il componente Map, reuseMaps={true} e l'esempio di clustering dei marker che utilizza @googlemaps/markerclusterer. Traccia la pulizia dei marker dei cluster durante la navigazione tra le viste delle città e determina perché i marker della città precedente rimangono. Il lavoro è completato quando il cambio di città non lascia più marker dei cluster delle viste precedenti sulla mappa memorizzata nella cache.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
I'm implementing an application that has a view /cities which allows you to view all cities on a google map. You can then navigate to view a specific cities at /cities/[id]. Each city then has markers for EV chargers in the city. The EV charger markers are clustered.
If I enable map instance caching via reuseMaps={true} I run into issues where cluster markers remain on the map as you navigate from one city to another. It's not obvious as you have to zoom out in order to see cluster markers from multiple cities.
I'm using @googlemaps/markerclusterer and the implementation follows the marker-clustering example in this repo.
I'm storing the cluster markers in an array stored in useRef in an attempt to be able to remove them when the component unmounts.
return new MarkerClusterer({
map,
renderer: {
render: (cluster, stats, map) => {
const markerElem = renderClusterMarker({
cluster,
map,
mapContentType,
});
// cluster markers are added to the array here
clusterMarkerElems.current.push(markerElem);
return markerElem;
},
},
});
Then on unmount I'm attempting to remove the cluster markers:
useEffect(() => {
return () => {
// This does not throw an error, but it does not seem to work
clusterMarkerElems.current.forEach((clusterMarkerElem) => {
clusterMarkerElem.setMap(null);
});
setMarkers({});
// markerClusterer is always null
if (markerClusterer) {
markerClusterer?.clearMarkers();
}
};
}, []);
The code in the cleanup function does not throw an error, but it also doesn't work. I have a guess that the <Map> component is already removed by the time the cleanup function runs. If I run markerClusterer.clearMarkers() when the view loads it doesn't remove the stranded markers as I don't think it knows they exist.
Steps to Reproduce
See description.
Environment
- Library version: 1.4.2
- Google maps version: weekly
- Browser and Version: Firefox latest
- OS: macOS
Logs
No response
- Lingua principale
- TypeScript
- Stelle
- 1.9k
- Fork
- 195
- Merge medio
- 2g 11h
- PR unite (30g)
- 14
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di visgl/react-google-maps
-
google maps issue
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
visgl/react-google-maps#1080 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
bug needs more info
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
visgl/react-google-maps#1039 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
visgl/react-google-maps#918 · 9 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
visgl/react-google-maps#905 ·
I maintainer di solito rispondono entro 2 giorni
-
google maps issue
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
visgl/react-google-maps#889 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di visgl/react-google-maps
Issue simili
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
inu-appcenter/memorIN-frontend#106 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 7 giorni
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
fix: CopyFilters ignores tabApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
CSCfi/sd-search-ui#145 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Cbeebies pl SDApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno