私のアプリケーションには、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()
足りないものがあると思いますが、見つかりません