Hello, I am trying to implement a GetFeature control in a GeoExt map panel but cannot get it to return a selected feature (in IE 8 or Firefox 3.5.1). I have tried a really simple example using the OpenLayers getfeature-wfs.html example and adding the map to GeoExt mapPanel, but it does not highlight a feature or add one to the vector layer, although the cursor does briefly change to a crosshair, as if something is happening. In the application that I am writing I want to link the getfeature control to a toolbar item. Can anyone tell me what I am doing wrong, please? Thanks anneb
the js code is here:
var map, layer, select, hover, control;
Ext.onReady(function() {
OpenLayers.ProxyHost= "proxy.cgi?url=";
Ext.BLANK_IMAGE_URL = '../ext-3.2.1/resources/images/default/s.gif';
var options = {
controls: [
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.Navigation()
]
};
map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.WMS(
"States WMS/WFS",
"http://v2.suite.opengeo.org/geoserver/ows",
{layers: 'usa:states', format: 'image/gif'}
);
select = new OpenLayers.Layer.Vector("Selection", {
styleMap: new
OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
});
hover = new OpenLayers.Layer.Vector("Hover");
map.addLayers([layer, hover, select]);
control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
box: true,
hover: true,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});
control.events.register("featureselected", this, function(e) {
select.addFeatures([e.feature]);
});
control.events.register("featureunselected", this, function(e) {
select.removeFeatures([e.feature]);
});
control.events.register("hoverfeature", this, function(e) {
hover.addFeatures([e.feature]);
});
control.events.register("outfeature", this, function(e) {
hover.removeFeatures([e.feature]);
});
map.addControl(control);
control.activate();
mapPanel = new GeoExt.MapPanel({
title: "GeoExt MapPanel",
renderTo: "mappanel",
stateId: "mappanel",
height: 400,
width: 600,
map: map,
center: new
OpenLayers.Bounds(-140.444336,25.115234,-44.438477,50.580078).getCenterLonLat(),
zoom: 3
});
});
http://www.jbaconsulting.co.uk/
JBA Consulting
South Barn
Broughton Hall
Skipton
North Yorkshire
BD23 3AE
United Kingdom
http://www.jbaconsulting.co.uk/?q=nce-winner-2010
t: +44 (0)1756 799919 | f: +44 (0)1756 799449
JBA is a Carbon Neutral Company. Please don't print this e-mail unless you
really need to.
This email is covered by JBA Consulting's
http://www.jbaconsulting.co.uk/emaildisclaimer.
<<image/gif>>
<<image/gif>>
_______________________________________________ Users mailing list [email protected] http://www.geoext.org/cgi-bin/mailman/listinfo/users
