【发布时间】:2017-02-23 20:09:41
【问题描述】:
我正在工作 Openlayers 3。我在地图上添加了三层WMS,顺序如下:公社、区、省。我在缩放时使用 "forEachLayerAtPixel" 来获取当前图层的信息。 示例: 当缩放到图层District 得到信息图层District,或者缩放到图层Commune 得到信息图层Commune。但是它只获取图层省份的信息,当缩放到图层District时返回“undefined”。我使用事件 "pointermove" 在地图上悬停:
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);
【问题讨论】:
-
嗨,你有什么问题?
-
不要返回层,否则它将停止搜索。将日志放在回调中。
标签: openlayers openlayers-3 geoserver ol3-google-maps