wfs功能onSelect事件在firefox中不起作用

时间:2013-09-05 12:05:39

标签: javascript openlayers

我想从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 Explore中运行良好,但在firefox或Chrome中无效(单击该功能时无响应)。 我想知道它是否与交叉访问有关,但我使用proxy.cgi,它可以工作。

所以有人请告诉我我的代码有什么问题?或者还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

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

在你的情况下:

var click = new OpenLayers.Control.SelectFeature([featureLayer, otherFeatureLayer], { onSelect: createPopup,         onUnselect: destroyPopup })