Thanks a lot for all the inputs you have given.<br>In fact with GeoJSON everything goes smoothly.<br><br>Cheers,<br>Hugo<br><br><div class="gmail_quote">On Mon, Mar 8, 2010 at 7:20 PM, Eric Lemoine <span dir="ltr"><<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Saturday, March 6, 2010, Hugo <<a href="mailto:hfpmartins@gmail.com">hfpmartins@gmail.com</a>> wrote:<br>
> Hello all,<br>
><br>
> 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.<br>
> Following, is the relevant part of the code:<br>
><br>
> var connect = new Ext.data.Connection();<br>
> connect.request({<br>
> url: 'mfbase/geoquery.php',<br>
> params: {<br>
> species: species,<br>
> datai: datai,<br>
> dataf: dataf<br>
> },<br>
> success: function(response){<br>
> var resp = response.responseText;<br>
> var json = new OpenLayers.Format.JSON();<br>
> var data = json.read(resp);<br>
> //console.log(data[0].the_geom);<br>
><br>
> var querylayer1 = new OpenLayers.Layer.Vector(<br>
> 'Query1',<br>
> {<br>
> isBaseLayer: false,<br>
> projection: wgs,<br>
> geometryName: 'the_geom',<br>
> }<br>
> );<br>
><br>
> querylayer1.addFeatures(data);<br>
<br>
</div>addFeatures should receive an array of OpenLayers.Feature.Vector objects.<br>
<br>
How are geometries encoded in your JSON responses? If they are encoded<br>
as WKT you will also need OpenLayers.Format.WKT.<br>
<br>
Have you considered using GeoJSON? Using GeoJSON your client code will<br>
be simpler.<br>
<br>
Cheers,<br>
<div class="im"><br>
> map.addLayer(querylayer1);<br>
> }<br>
> })<br>
> Any suggestions are more than welcomed :)<br>
> Thanks to you all!<br>
><br>
> Cheers,<br>
><br>
><br>
> --<br>
> Hugo Martins<br>
> FMV-UTL<br>
> CIISA-Epidemiologia e Saúde Pública Veterinária<br>
> Av. da Universidade Técnica<br>
> 1300-477 Lisboa<br>
> N 38°42'49.54", W 9°11'43.42"<br>
><br>
<br>
</div>--<br>
Eric Lemoine<br>
<br>
Camptocamp France SAS<br>
Savoie Technolac, BP 352<br>
73377 Le Bourget du Lac, Cedex<br>
<br>
Tel : 00 33 4 79 44 44 96<br>
Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Hugo Martins<br>FMV-UTL<br>CIISA-Epidemiologia e Saúde Pública Veterinária<br>Av. da Universidade Técnica<br>1300-477 Lisboa<br>N 38°42'49.54", W 9°11'43.42"<br>