打开图层 wms 弹出窗口不起作用



我构建了一个开放图层地图,我想实现一个弹出窗口。我正在关注一些谷歌创立的资源:http://lists.osgeo.org/pipermail/openlayers-users//2011-August/021680.html

代码为:

<script type="text/javascript">
   var map;
   var osm;
   var layer;
   var info;
   function init() {
         var bounds = new OpenLayers.Bounds(
                1160036.31025726, 7444371.48007091,
                1160792.70130936, 7444966.36493288
                );
         map = new OpenLayers.Map("map", {
                maxExtent: bounds,
 });
     osm =new OpenLayers.Layer.OSM({visibility: true});
     layer = new OpenLayers.Layer.WMS(
                "Working Field", "http://localhost:8080/geoserver/layer/wms",
                {
                layers: 'layer:layer',
                transparent: true,
                isBaseLayer: false
                },
                {
                sphericalMercator: true,                        
                opacity: 0.5
                }
            );

          map.addLayers([osm,layer]);
          map.zoomToExtent(bounds);
   info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: "http://localhost:8080/geoserver/wms",
            //layerUrls: 'http://localhost:8080/geoserver/layer/wms',
    title: 'Identify features by clicking',
            layers: [acm],
    queryVisible: true,
    infoFormat: 'text/html',
    maxFeatures: 1,
    eventListeners: {
        getfeatureinfo: function(event) {
            if (event.text.indexOf("<table class="featureInfo">") != -1){
                popup = new OpenLayers.Popup.FramedCloud(
                    "chicken", 
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true
                ), {
                    autoSize: false,
                    maxSize: new OpenLayers.Size(5,5)
                };
                map.addPopup(popup);
            }
        }
    }
});
map.addControl(info);
  }
 </script>

任何关于问题所在的线索都会有所帮助。谢谢!

实际上层:

[acm] 没有定义,还有一件事是我们需要激活信息控件,例如:

info.activate();

最新更新