私はこれが事実の後にあることを知っていますが、私が解決策を探していたときにあなたの質問を見つけました。私はようやく問題を抱えている場合や、他の人が問題を経験している場合に備えて、最終的に機能するものをここに含めたいと思っていました。
複数のレイヤーに結果を表示し、古いレイヤーを「しばらくして」削除すると答えた回答がいくつか見つかりましたが、それは私には気になりませんでした。リーフレットイベントを使用して、私はそれらの答えの精神に従った解決策を見つけましたが、それでもきれいに感じます。私はグリッドを作成するためにvectorGrid.slicerを使用していますので、グリッドレイヤを作成するために使用しているものと置き換えてください。
// Function to handle event from leaflet when all tiles are loaded
// for the grid layer
const onLoad = (e) => {
// Use a brief timeout so the new layer has time to draw before
// the old layer is removed. This prevents a brief blink of the layers.
setTimeout(
() => {
// Remove the old grid layer from the map
this.graphicsLayer.remove();
// Stop listening to the load event
e.target.off('load', onLoad);
// Save the new graphics layer into the member variable
this.graphicsLayer = e.target;
},
250
);
};
// Create the grid layer, and listen to the load event
L.vectorGrid.slicer(geographyResults, slicerStyle)
.on('load', onLoad).addTo(this.map);
私は同じ問題を抱えていますが、解決策を見つけることになりましたか? –