[Users] Help with OpenLayers.Format.GeoJSON

Pol d.paolino at gmail.com
Fri Sep 17 09:40:24 CEST 2010


Hello Eric, all,

I tried your advice and it doesn't work here.

I join you 2 screenshots where you can see what I'm doing.

I'm really lost into this, I've tried with different versions of firefox,
always the same result...

Thanks for helping!

-Pol D.-
http://www.google.com/profiles/110003197662276240659


On Wed, Sep 15, 2010 at 08:57, Eric Lemoine <eric.lemoine at camptocamp.com>wrote:

> On Wed, Sep 15, 2010 at 8:21 AM, Pol <d.paolino at gmail.com> wrote:
> > Yes I tried also to do that, but the thing that worry me the most is that
> > console.log() do not display anything...
>
> This is weird.
>
> Overriding read works for me. In the FireBug console:
>
> >>> var f = new OpenLayers.Format.GeoJSON({read: function(str) {
> console.log(str); }});
> >>> f.read("foo");
> foo
>
> Likewise the following patch to the feature-grid.html example works for me:
>
> diff --git examples/feature-grid.js examples/feature-grid.js
> index 04cf945..d9419e6 100644
> --- examples/feature-grid.js
> +++ examples/feature-grid.js
> @@ -48,7 +48,12 @@ Ext.onReady(function() {
>          proxy: new GeoExt.data.ProtocolProxy({
>             protocol: new OpenLayers.Protocol.HTTP({
>                  url: "data/summits.json",
> -                format: new OpenLayers.Format.GeoJSON()
> +                format: new OpenLayers.Format.GeoJSON({
> +                    read: function() {
> +                        console.log("in read");
> +                        return
> OpenLayers.Format.GeoJSON.prototype.read.apply(this, arguments);
> +                    }
> +                })
>             })
>         }),
>         autoLoad: true
>
>
> > I've modified my code like this:
> > MarkersStore = new GeoExt.data.FeatureStore({
> > layer: MarkersLayer,
> > proxy: new GeoExt.data.ProtocolProxy({
> > protocol: new OpenLayers.Protocol.HTTP({
> > url: marker_api_url,
> > format: new OpenLayers.Format.GeoJSON({
> > read: function() {
> > console.log("testing...");
> >                         var obj = OpenLayers.Format.JSON.read.apply(this,
> > arguments);
> >     return OpenLayers.Format.GeoJSON.read.apply(this, obj['#data']);
> >         },
> > 'internalProjection': proj900913,
> > 'externalProjection': proj4326
> > }),
> > readWithPOST: true
> > })
> > }),
> > autoLoad: true,
> > });
> > Any idea?
>
>
> Patching the feature-grid.html example has made me realize that
> there's something wrong in the above code. The read method is
> obviously set in the prototype, so OpenLayers.Format.JSON.read should
> be OpenLayers.Format.JSON.prototype.read, and likewise for
> Format.GeoJSON.
>
>
> --
> 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/20100917/b963c251/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen shot 2010-09-17 at 9.36.03 AM.png
Type: image/png
Size: 419087 bytes
Desc: not available
Url : http://www.geoext.org/pipermail/users/attachments/20100917/b963c251/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen shot 2010-09-17 at 9.35.32 AM.png
Type: image/png
Size: 348468 bytes
Desc: not available
Url : http://www.geoext.org/pipermail/users/attachments/20100917/b963c251/attachment-0003.png 


More information about the Users mailing list