<div>Thanks Eric, but...</div><div><br></div>How to include such code in my current application ?<div><br></div><div>I'm doing these:</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>
<font face="'courier new', monospace">MyReader = new OpenLayers.Format.GeoJSON({</font></div><div class="im" style="color: rgb(80, 0, 80); "><div><span style="white-space: pre-wrap; "><font face="'courier new', monospace">                </font></span><font face="'courier new', monospace">read: function() {</font></div>
<div><font face="'courier new', monospace"> </font><span style="white-space: pre-wrap; "><font face="'courier new', monospace">                </font></span><font face="'courier new', monospace">var obj = OpenLayers.Format.JSON.read.apply(this, arguments);</font></div>
</div><div><font face="'courier new', monospace"> </font><span style="white-space: pre-wrap; "><font face="'courier new', monospace">                </font></span><font face="'courier new', monospace">return OpenLayers.Format.GeoJSON.read.apply(this, obj->#data);</font></div>
<div><font face="'courier new', monospace"> </font><span style="white-space: pre-wrap; "><font face="'courier new', monospace">                </font></span><font face="'courier new', monospace">}</font></div>
<div><font face="'courier new', monospace"> </font><span style="white-space: pre-wrap; "><font face="'courier new', monospace">        </font></span><font face="'courier new', monospace">});</font></div><div>
<font face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">And then ? I don't know how to use it in my store...</font></div></span></div><div>
<br></div><div>Thanks for helping !</div><div><br></div><div><br clear="all">-Pol D.-<br><br><div class="gmail_quote">On Mon, Sep 13, 2010 at 19:04, 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="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5">On Monday, September 13, 2010, Pol <<a href="mailto:d.paolino@gmail.com">d.paolino@gmail.com</a>> wrote:<br>
> Hello all,<br>
> I'm moving my whole project to the Drupal Framework and I'm using the services module who can send data in many format(xml, json, amfphp, etc etc).<br>
> Before using it, I was using simple php to send the data to my store, like this:<br>
><br>
> MarkersStore = new GeoExt.data.FeatureStore({<br>
> layer: MarkersLayer,<br>
> proxy: new GeoExt.data.ProtocolProxy({<br>
> protocol: new OpenLayers.Protocol.HTTP({<br>
> url: get_markers.php,<br>
> format: new OpenLayers.Format.GeoJSON({<br>
> 'internalProjection': proj900913,<br>
> 'externalProjection': proj4326<br>
> }),<br>
> readWithPOST: true<br>
> })<br>
> }),<br>
> autoLoad: false,<br>
> });<br>
><br>
> Now I have to modify my code to get it working with the tools provided by this amazing framework.<br>
> My Json code look like this now:<br>
> { "#error": false,<br>
> "#data": {<br>
> "type": "FeatureCollection",<br>
> "features": [<br>
> {<br>
> "geometry": {<br>
> "type": "Point",<br>
> "coordinates": [<br>
> 4.35205865469,<br>
> 50.8235093311<br>
> ]<br>
> },<br>
> "properties": {<br>
> "img": "sites/default/modules/lukoil/lukoil.jpg",<br>
> "inf": "Lukoil ID 3",<br>
> "html": null<br>
> }<br>
> }]<br>
> }<br>
> }<br>
><br>
> The FeatureCollection I use to parse is now embedded in another container.<br>
> That means that my old FeatureStore is no more working with those data and I don't know how to solve this.<br>
><br>
> Any idea ?<br>
> My store look like this now:<br>
> MarkersStore = new GeoExt.data.FeatureStore({<br>
> layer: MarkersLayer,<br>
> proxy: new GeoExt.data.ProtocolProxy({<br>
> protocol: new OpenLayers.Protocol.HTTP({<br>
> url: /services/json,<br>
> params: {'method':'\"markers.get\"'},<br>
> format: new OpenLayers.Format.GeoJSON({<br>
> 'internalProjection': proj900913,<br>
> 'externalProjection': proj4326<br>
> }),<br>
> readWithPOST: true<br>
> })<br>
> }),<br>
> autoLoad: false,<br>
> });<br>
><br>
> Thanks for the help !<br>
<br>
</div></div>Hi<br>
<br>
This framework isn't so amazing since it doesn't support GeoJSON.<br>
Sorry I couldn't resist :-)<br>
<br>
The representation format of the received data is not GeoJSON, so it's<br>
no surprise that Format. GeoJSON cannot read that.<br>
<br>
What you can do is define your own Format, with something like that for example:<br>
<br>
new OpenLayers.Format.GeoJSON({<br>
read: function() {<br>
var obj = OpenLayers.Format.JSON.read.apply(this, arguments);<br>
return OpenLayers.Format.GeoJSON.read.apply(this, [obj]);<br>
}<br>
});<br>
<br>
Cheers,<br>
<br>
--<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></div>