[OpenLayers-Users] Problem extracting attributes from WFS
Arnd Wippermann
arnd.wippermann at web.de
Wed Apr 22 14:40:37 EDT 2009
Hi,
> Should it not be possible to extract attributes from the feature, when the
WFS constructor is given the > "extractAttributes:true" option?
Yes.
But perhaps your attributes have to be like
...
<feature:type>0</feature:type>
<feature:name>Type 0</feature:name>
<feature:description>Feature Type</feature:description>
...
So that OL is able to parse them.
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Hans Gregers Petersen
Gesendet: Mittwoch, 22. April 2009 16:30
An: users at openlayers.org
Betreff: [OpenLayers-Users] Problem extracting attributes from WFS
Hi All,
I am currently trying to get OpenLayers + Geoserver + PostGIS working.
I use Geoserver to serv features to Openlayers (via WFS) and the points are
added to the map as they are supposed to.
My problem is getting the attribute dato from each feature, I can extract
feature.fid, which is correct, but nothing is available from
feature.attributes.
Should it not be possible to extract attributes from the feature, when the
WFS constructor is given the "extractAttributes:true" option?
I have googled and googled (there does not seem to be more than a number of
people using WFS + attributes?), and tried a number of things so any help or
hints would be great.
Best Regards,
Gregers Petersen
A sample of the returned GML is:
<gml:featureMember>
<paspunkter:punkter fid="punkter.1">
<paspunkter:x>43.4</paspunkter:x>
<paspunkter:y>47.12</paspunkter:y>
<paspunkter:z>23.1</paspunkter:z>
<paspunkter:kvalitetplan>1.2</paspunkter:kvalitetplan>
<paspunkter:latlon>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#900913">
<gml:coordinates decimal="." cs="," ts="
">1322846.5784869,7360249.01559515</gml:coordinates>
</gml:Point>
</paspunkter:latlon>
</paspunkter:punkter>
</gml:featureMember>
The relevant parts of my JavaScript code is:
function onFeatureSelect(feature) {
selectedFeature = feature;
var streng = "<div style='font-size:.8em'>Feature: " + feature.fid +
"<br/>Attributes:";
for(var i in feature.attributes)
streng += "<br/><b>" + i + "</b>: "+ feature.attributes[i];
streng += "</div>"
popup = new OpenLayers.Popup.FramedCloud("GlibGlab",
feature.geometry.getBounds().getCenterLonLat(),
null,
streng,
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
/* snip */
function init(){
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
map = new OpenLayers.Map( 'map', options );
// Google Satellite
var googleSatLayer = new OpenLayers.Layer.Google("Google
Satellite",{type: G_SATELLITE_MAP, sphericalMercator:true,
numZoomLevels: 21 });
map.addLayer(googleSatLayer);
/* snip */
// Our paspunkt layer
var ppLayer = new OpenLayers.Layer.WFS( "Paspunkter",
"WFSproxy.ashx?",
{typename: "paspunkter:punkter",
extractAttributes:true, displayInLayerSwitcher:false});
map.addLayer(ppLayer);
/* snip */
}
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list