[OpenLayers-Users] GML layer

Pablo Cabrera pablo at softplan.com.br
Wed Aug 25 07:10:34 EDT 2010


  You might need to setup a proxy to get GML and WFS layers, since they 
fetch them with XmlHttpRequest...

On 25/08/2010 05:12, ilias kanellos wrote:
> 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?
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Pablo Cabrera
Analista Implementador
Softplan/Poligraph
Fone: (48) 3027.8000
http://www.softplan.com.br

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100825/7f0691fe/attachment.html


More information about the Users mailing list