在我的应用程序中,我有一个 googlemap 和一些来自 geoserver 的 WMS 图层,我需要选择这些图层上的功能,我遵循了这个示例: http: //openlayers.org/dev/examples/getfeature-wfs.html,我得到了没有错误,当我单击某个功能时,鼠标开始旋转,但根本没有结果,这是我的代码:
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{"type": google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
);
var options = {
controls: [],
//sphericalMercator:true,
//projection: new OpenLayers.Projection('EPSG:900913'), // senza la proiezione mi stampa metà layer
units: "m",
numZoomLevels: 22,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
var panZoom = new OpenLayers.Control.PanZoom();
var map = new OpenLayers.Map('map', {
div: "gmap",
projection: "EPSG:900913",
displayProjection: "EPSG:4326",
//zoomOffset: 5
controls: [
panZoom,
new OpenLayers.Control.Navigation()
]
});
var regioni = new OpenLayers.Layer.WMS(
"regioni",
"http://localhost:8080/geoserver/wms",
{
layers: "metmi-italy:reg2011_g" ,
transparent: "true",
format: "image/png",
srs:'EPSG:900913', // old: 'EPSG:2077'
//zoomOffset: 4,
},
{isBaseLayer: false,}
);
control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(regioni),
box: true,
hover: true,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});
select = new OpenLayers.Layer.Vector("Selezioni", {styleMap:
new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
});
map.addLayers([ghyb,regioni,select])
control.events.register("featureunselected", this, function(e) {
removeFeaturesFromGrid(e.feature.fid);
select.removeFeatures([e.feature]);
});
control.events.register("featureselected", this, function(e) {
console.log('selected')
select.addFeatures([e.feature]);
//addFeaturesToGrid(e.feature);
});
map.addControl(control);
control.activate()
我认为缺少某些东西,但我没有找到