Hi all,
I'm still rather green with openlayers but what I am trying to do is get
popups in my vector layer which currently uses a WFS protocol. I have
been unable to figure out how to do this. All I get is an undefined
message in my popup. I realize this is must be because openlayers is not
retrieving the attribute information from the WFS response from the
server, or maybe I am not calling it right in my pop up.
OpenLayers.Layer.WFS has an option called {extractAtrributes} which can be
set to true. The protocol I am using however does not seem to have such
an option and I was wondering if that could be my problem. However, I
understand that using the OpenLayers.Layer.WFS is somewhat outdated? I am
getting the features to appear in my vector layer and I am getting a popup
window with some geometry stuff but Im getting an undefined message for
the attribute "luname" (feature.luname).
I think I am either not calling the attribute right in my javascript or it
is not being retrieved from the server xml response. any ideas?
My JavaScript is below please help if ya can!!
var map, selectControl,selectedFeature;
function onPopupClose(evt) {
selectControl.unselect(selectedFeature);
}
function onFeatureSelect(feature) {
selectedFeature = feature;
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
"<div style='font-size:.8em'>Feature:
" + feature.luname +"<br />Area: " + feature.geometry.getArea()+"</div>",
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
function init() {
OpenLayers.ProxyHost= "proxy.php?url=";
map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS", "
http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}
);
var layer = new OpenLayers.Layer.Vector("lupoints", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url: "http://igsaceeswsmwime:8080/geoserver/wfs",
featureType: "lupoints",
featureNS: "
http://igsaceeswsmwime:8080/geoserver/monitoring",
})
});
map.addLayers([wms, layer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
selectControl = new
OpenLayers.Control.SelectFeature(layer,
{onSelect: onFeatureSelect, onUnselect:
onFeatureUnselect});
map.addControl(selectControl);//I added
selectControl.activate();
map.setCenter(new OpenLayers.LonLat(-90, 38), 3);
}
_______________________________________________
Users mailing list
us...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users