1
我構建了一個openLayers貼圖,我想實現一個彈出窗口。我下面一些谷歌創立的資源: http://lists.osgeo.org/pipermail/openlayers-users//2011-August/021680.htmlopenLayers wms彈出窗口不起作用
的代碼是:
<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>
什麼是錯的,將有助於任何線索。謝謝!
感謝您的反饋意見。我用[layer]更改了[acm],並添加了info.activate();但仍然不起作用。 –
可能是你在這行失敗if(event.text.indexOf(「
該代碼查看OpenLayers.Control.WMSGetFeatureInfo中是否存在一些表信息,並用於指出製作的人,以獲得僅用於彈出窗口的一層,它具有一些屬性。 –
相關問題