[Users] Help with OpenLayers.Format.GeoJSON

Pol d.paolino at gmail.com
Mon Sep 13 21:52:35 CEST 2010


Thanks Eric, but...

How to include such code in my current application ?

I'm doing these:

MyReader = new OpenLayers.Format.GeoJSON({
read: function() {
          var obj = OpenLayers.Format.JSON.read.apply(this, arguments);
          return OpenLayers.Format.GeoJSON.read.apply(this, obj->#data);
      }
  });

And then ? I don't know how to use it in my store...

Thanks for helping !


-Pol D.-

On Mon, Sep 13, 2010 at 19:04, Eric Lemoine <eric.lemoine at camptocamp.com>wrote:

> On Monday, September 13, 2010, Pol <d.paolino at gmail.com> wrote:
> > Hello all,
> > 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).
> > Before using it, I was using simple php to send the data to my store,
> like this:
> >
> >       MarkersStore = new GeoExt.data.FeatureStore({
> >               layer: MarkersLayer,
> >               proxy: new GeoExt.data.ProtocolProxy({
> >                       protocol: new OpenLayers.Protocol.HTTP({
> >                               url: get_markers.php,
> >                               format: new OpenLayers.Format.GeoJSON({
> >                                       'internalProjection': proj900913,
> >                                       'externalProjection': proj4326
> >                               }),
> >                               readWithPOST: true
> >                       })
> >               }),
> >               autoLoad: false,
> >       });
> >
> > Now I have to modify my code to get it working with the tools provided by
> this amazing framework.
> > My Json code look like this now:
> > {    "#error": false,
> >     "#data": {
> >         "type": "FeatureCollection",
> >         "features": [
> >             {
> >                 "geometry": {
> >                     "type": "Point",
> >                     "coordinates": [
> >                         4.35205865469,
> >                         50.8235093311
> >                     ]
> >                 },
> >                 "properties": {
> >                     "img": "sites/default/modules/lukoil/lukoil.jpg",
> >                     "inf": "Lukoil ID 3",
> >                     "html": null
> >                 }
> >             }]
> >       }
> > }
> >
> > The FeatureCollection I use to parse is now embedded in another
> container.
> > That means that my old FeatureStore is no more working with those data
> and I don't know how to solve this.
> >
> > Any idea ?
> > My store look like this now:
> >       MarkersStore = new GeoExt.data.FeatureStore({
> >               layer: MarkersLayer,
> >               proxy: new GeoExt.data.ProtocolProxy({
> >                       protocol: new OpenLayers.Protocol.HTTP({
> >                               url: /services/json,
> >                               params: {'method':'\"markers.get\"'},
> >                               format: new OpenLayers.Format.GeoJSON({
> >                                       'internalProjection': proj900913,
> >                                       'externalProjection': proj4326
> >                               }),
> >                               readWithPOST: true
> >                       })
> >               }),
> >               autoLoad: false,
> >       });
> >
> > Thanks for the help !
>
> Hi
>
> This framework isn't so amazing since it doesn't support GeoJSON.
> Sorry I couldn't resist :-)
>
> The representation format of the received data is not GeoJSON, so it's
> no surprise that Format. GeoJSON cannot read that.
>
> What you can do is define your own Format, with something like that for
> example:
>
>    new OpenLayers.Format.GeoJSON({
>         read: function() {
>             var obj = OpenLayers.Format.JSON.read.apply(this, arguments);
>             return OpenLayers.Format.GeoJSON.read.apply(this, [obj]);
>         }
>     });
>
> Cheers,
>
> --
> Eric Lemoine
>
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac, Cedex
>
> Tel : 00 33 4 79 44 44 96
> Mail : eric.lemoine at camptocamp.com
> http://www.camptocamp.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100913/28015d62/attachment.htm 


More information about the Users mailing list