[OpenLayers-Users] GML layer
ilias kanellos
ilias.kanellos at gmail.com
Wed Aug 25 04:12:33 EDT 2010
Hello,
I am trying to read a GML and put it on my map. From what I've read, the
correct way to do so is to use a vector layer that will read a file with GML
format.
As I am still just trying to understand how this works, I am trying to
create a layer, as it is done on the openLayers example page. More
specifically, I am
trying to make a layer from this file:
http://openlayers.org/dev/examples/gml/polygon.xml
However something seems to go wrong, either with the layer itself, or with
adding the layer to the map. I am not sure where exactly. My code looks like
this:
var newGMLOverlay = new OpenLayers.Layer.Vector("GML",
{
strategies: [new
OpenLayers.Strategy.Fixed()],
protocol: new
OpenLayers.Protocol.HTTP(
{
url: "
http://openlayers.org/dev/examples/gml/polygon.xml",
format: new
OpenLayers.Format.GML(
{
extractAttributes:
true
})
})
});
alert("Number of features is " +
newGMLOverlay.features.length);
map.addLayer(newGMLOverlay);
The alert commad shows me that there are no features in the vector layer I
created, and nothing displays on the map.
I already have a vector layer that is on the map, that is added when the map
is initialised. Both the original vector layer and the GML display on the
layerswitcher,
but nothing is displayed for gml. Do I need to take an extra step (like
somehow parsing the file of the url) in order to display the features from
the GML file on my map,
or am I doing something else wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100825/283e60ed/attachment.html
More information about the Users
mailing list