【问题标题】:Openlayers 3 forEachLayerAtPixel get only layerOpenlayers 3 forEachLayerAtPixel 只获取层
【发布时间】: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


【解决方案1】:

大概的问题是:如何用forEachLayerAtPixel的方法来追踪一个特定的层? 因为显然总是返回未定义的又名变量未设置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多