Hi,
Your code seems fine. In firebug, if you look the 'attributes' property
of any of the vector features of your layer, do you the feature's
attributes ?
mywfs.features[0].attributes
Regards,
Alexandre
On 10-11-22 10:47 AM, pawprint_net wrote:
In short: How do you get attribute data (easiest way) from a server (php in
my case) to a vector layer.
I'm trying to set up what I believe is a fairly straightforward system but
can't see how to make it work, checked docs, and many examples but it's just
not doing what I need. I could well be doing something wrong with name
spaces and the like really not sure about that.
Desired End Result: A map with point features from my custom-built php
server that has labels with the name of the feature. I have complete control
over the client side and the server side of this one (looking for the
simplest way to do this) - at some point in the future I'd like to extend
this to read additional attribute data to display a pop-up on click and
perhaps also show things other then just points - but for now I'm just
trying to get this to work.
Here is what my server is putting out (can easily be changed):
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"
xmlns:xde="http://www.example.com/myns"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd">
<gml:boundedBy>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coordinates decimal="." cs="," ts=" ">
-124.58021460938,48.783354492188,-122.93226539062,50.156645507812
</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<xde:asset fid="asset.71">
<xde:name>Alberni Responder</xde:name>
<xde:geometry>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coordinates>-124.812,49.2443</gml:coordinates>
</gml:Point>
</xde:geometry>
</xde:asset>
</gml:featureMember>
etc...
</wfs:FeatureCollection>
And here is my OL config:
function init(){
var lat = 49.47;
var lon = -123.75624
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 4;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
options = {resolutions:[1.40625, 0.3515625, 0.087890625,
0.02197265625, 0.0054931640625, 0.00274658203125, 0.001373291015625,
0.0006866455078125, 0.00034332275390625, 0.000171661376953125,
8.58306884765625e-05, 4.291534423828125e-05],
projection:"EPSG:4326",
controls: []};
map = new OpenLayers.Map( 'map',options );
layer = new OpenLayers.Layer.WMS(<approperiate layer options
here - this works fine>);
mywfs = new OpenLayers.Layer.Vector("Features", {
strategies: [new OpenLayers.Strategy.BBOX()],
styleMap: new OpenLayers.StyleMap({fillColor: "#ff0000",
strokeColor:
"#990000",
strokeWidth: 1,
fillOpacity: 0.9,
pointRadius: 5,
label: "${name}"
}),
protocol: new OpenLayers.Protocol.HTTP({url:
"http://<path to my php here>",
params: {
format:
"WFS",
service:
"assets",
request:
"GetFeatures",
srs:
"EPSG:4326",
maxfeatures:
50
},
format: new
OpenLayers.Format.GML({featurePrefix:'xde',
featureName: 'xde:asset',
extractAttributes: true}),
})
});
map.addLayers([layer,mywfs]);
The resulting map shows the features but no labels and seems to completely
disregard my attempt to style them. If anyone can see what I'm doing wrong,
point me to a similar example, or suggest a better method I'd be very
appreciative.
-----
Fair Winds, and watch for squalls from leeward
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users