1
私は働いていますOpenlayers 3。地図上に次のように3つのWMSレイヤーを追加しました:コミューン、ディストリクト、州。私は"forEachLayerAtPixel"を使ってズーム時の現在のレイヤーの情報を取得しました。 例:レイヤーにズームすると、情報レイヤーを取得するか、レイヤーをズームしてレイヤーにしてから、情報レイヤーを取得します。しかしそれは層の情報を得るだけで、層の層にズームすると"未定義"を返します。私は、地図上のホバーのイベント「pointermove」を使用:Openlayers 3 forEachLayerAtPixelレイヤーを取得
map.on("pointermove", function (evt) {
if (evt.dragging) return;
const hit = map.forEachLayerAtPixel(evt.pixel, (layer) => {
if (layer instanceof ol.layer.Tile)
return layer;
return null;
});
console.log(hit);
こんにちは、あなたの質問は何ですか? – feedMe
レイヤーを戻さないでください。検索が停止します。ログをコールバックの中に入れてください。 –
[http://stackoverflow.com/help/how-to-ask](http://stackoverflow.com/help/how-to-ask) –