[OpenLayers-Users] Make vector layer from JSON

Arnd Wippermann arnd.wippermann at web.de
Sat Mar 6 16:43:03 EST 2010


Hi,
 
i would think, that you have to use geojson instead of json, to get the
geometry for the features.
 
Arnd

  _____  

Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Hugo
Gesendet: Samstag, 6. März 2010 19:14
An: openlayers
Betreff: [OpenLayers-Users] Make vector layer from JSON


Hello all,

I'm trying to create a vector layer based on a php query (which includes
the_geom) encoded in JSON. Until the moment i haven't been able to achieve
this.
Following, is the relevant part of the code:

var connect = new Ext.data.Connection();
connect.request({
    url: 'mfbase/geoquery.php',
    params: {
        species: species,
        datai: datai,
        dataf: dataf
    },
    success: function(response){
        var resp = response.responseText;
        var json = new OpenLayers.Format.JSON();
        var data = json.read(resp);
        //console.log(data[0].the_geom);
        
        var querylayer1 = new OpenLayers.Layer.Vector(
            'Query1',
            {
                isBaseLayer: false,
                projection: wgs,
                geometryName: 'the_geom',
            }
        );
        
        querylayer1.addFeatures(data);
        map.addLayer(querylayer1);
    }
})

Any suggestions are more than welcomed :)
Thanks to you all!

Cheers,


-- 
Hugo Martins
FMV-UTL
CIISA-Epidemiologia e Saúde Pública Veterinária
Av. da Universidade Técnica
1300-477 Lisboa
N 38°42'49.54", W 9°11'43.42"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100306/07a85d1a/attachment.html


More information about the Users mailing list