Hello,<br><br>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. <br>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 <br>
trying to make a layer from this file: <a href="http://openlayers.org/dev/examples/gml/polygon.xml">http://openlayers.org/dev/examples/gml/polygon.xml</a><br>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:<br>
<br> var newGMLOverlay = new OpenLayers.Layer.Vector("GML", <br> {<br> strategies: [new OpenLayers.Strategy.Fixed()],<br>
protocol: new OpenLayers.Protocol.HTTP(<br> {<br> url: "<a href="http://openlayers.org/dev/examples/gml/polygon.xml">http://openlayers.org/dev/examples/gml/polygon.xml</a>",<br>
format: new OpenLayers.Format.GML(<br> {<br> extractAttributes: true<br>
}) <br> })<br> });<br> alert("Number of features is " + newGMLOverlay.features.length);<br>
map.addLayer(newGMLOverlay);<br><br>The alert commad shows me that there are no features in the vector layer I created, and nothing displays on the map.<br>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, <br>
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, <br>or am I doing something else wrong? <br>