Hi,
 
something like this should work:
 
var features = new OpenLayers.Format.GML().read(response);
 
if(features)
{
    if(features.constructor != Array)
        features = [features];
 
    for(var i=0;i<features.length;i++)
    {
        var ftLyr = new OpenLayers.Layer.Vector("Feature " + i);
        addLayer(ftLyr);
        ftLyr.addFeatures(features[i]);
    }
}

Arnd

  _____  

Von: [email protected] [mailto:[email protected]] Im
Auftrag von Alex Brandsen
Gesendet: Sonntag, 27. Juni 2010 14:43
An: Eric Lemoine
Cc: [email protected]
Betreff: Re: [OpenLayers-Users] parsing a GML file into different layers


Hi Eric,

thanks for your reply. I probably need to use OpenLayers. Format.GML.read()
, but how do I then split the array it returns into different layers?

Thanks,

Alex.


On Sat, Jun 26, 2010 at 7:12 AM, Eric Lemoine <[email protected]>
wrote:


On Friday, June 25, 2010, Alex Brandsen <[email protected]> wrote:
> Hi all,
>
> I'm building a map of a medieval wallpainting, and the graffiti inscribed
in this wall, which can be found on www.thomasav.com/DurhamGraffiti/ (still
quite buggy though!).
> I was wondering if there is a way for OpenLayers to dynamically turn
features from a single GML file into seperate layers, by providing an array
of feature id's. I've been looking through the documentation and been
googling around, but I can't seem to find anything useful. Perhaps
"OpenLayers. Filter. FeatureId" could do something like this, but the
documentation on this is quite sparse..
>
> Ofcourse, I could just write a php script that would pre-parse the gml
into seperate, temporary gml files, but I think using OpenLayers itself
would be preferable.
>
> If anyone has any ideas, I would be very grateful!



Hi

The protocol or format that you use will give you an array of
features. You are then free to dispatch the features to separate
vector layers, for example based on their ids.

I hope it helps,


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [email protected]
http://www.camptocamp.com



_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to