[Bug] Map instance caching has buggy behavior when used with clustering
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
まず、Map コンポーネント、reuseMaps={true}、および @googlemaps/markerclusterer を使用するマーカークラスタリングの例で説明されているナビゲーションフローを再現します。都市ビュー間のナビゲーション中にクラスター マーカーがクリーンアップされる過程を追跡し、前の都市のマーカーが残る理由を特定します。都市を変更しても、以前のビューのクラスター マーカーがキャッシュされたマップに残らなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 1.9k
- フォーク
- 195
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
visgl/react-google-maps のほかの issue
-
bug needs more info
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#1039 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
visgl/react-google-maps#918 · コメント 9 件 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
visgl/react-google-maps#905 ·
メンテナーはふだん 3 日以内に返信
-
google maps issue
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#889 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
visgl/react-google-maps#884 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
visgl/react-google-maps の issue をすべて見る
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
StabilityNexus/Fate-EVM-Frontend#153 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
code-yeongyu/oh-my-openagent#9039 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Tencent/teamai-cli#862 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue hacktoberfest redis
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
libredb/libredb-studio#1164 ·
メンテナーはふだん 1 日以内に返信
-
flake
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信