0

我想从 WFS 源加载功能,单击功能并弹出显示此功能信息的弹出窗口。我的代码是这样的:

` var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
  renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;
  featureLayer = new OpenLayers.Layer.Vector("WFS点图层", {
    version: "1.1.0",
    protocol: new OpenLayers.Protocol.WFS({
    url: "http://172.31.4.122:8090/iserver/services/data-XinDiTu/wfs100/utf-8",
    featureType: "BaseMap_P",
    featureNS: "http://www.supermap.com/newdata",
    featurePrefix:"newdata"
    }),
    renderers: renderer,
    strategies: [new OpenLayers.Strategy.BBOX()]
    });
    map.addLayer(featureLayer);
  var click = new OpenLayers.Control.SelectFeature(featureLayer, { onSelect: createPopup,         onUnselect: destroyPopup })
  map.addControl(click);
  click.activate();'

这在 Internet Explorer 中运行良好,但在 Firefox 或 Chrome 中运行良好(单击该功能时没有响应)。我想知道它是否与跨区域访问有关,但我使用的是proxy.cgi,它可以工作。

所以有人请告诉我我的代码有什么问题吗?或者有没有其他方法可以做到这一点?

4

1 回答 1

0

如果您使用多个矢量图层,请将它们全部添加到您的 SelectFeature 控件中。见http://openlayers.org/dev/examples/select-feature-multilayer.html

在你的情况下:

var click = new OpenLayers.Control.SelectFeature([featureLayer, otherFeatureLayer], { onSelect: createPopup,         onUnselect: destroyPopup })
于 2013-09-08T13:06:57.400 回答