[Users] Help with OpenLayers.Format.GeoJSON
Pol
d.paolino at gmail.com
Tue Sep 28 10:16:04 CEST 2010
Hello,
I succeded to get it working in firebug, I was using Firefox Beta 4 and
Firebug is having some issues with it.
Check this:
http://img163.imageshack.us/img163/5491/screenshot20100928at100.png
The code related to that screenshot is there: http://gist.github.com/600596 or
here:
MarkersStore = new GeoExt.data.FeatureStore({
layer: MarkersLayer,
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.HTTP({
url: marker_api_url,
params:{'method':'\"markers.get\"'},
format: new OpenLayers.Format.GeoJSON({
read: function() {
console.log("var This: " + this);
console.log("var arguments: " + arguments);
var obj =
OpenLayers.Format.JSON.prototype.read.apply(this, arguments);
console.log("var obj: " + obj);
return OpenLayers.Format.GeoJSON.prototype.read.apply(this, obj["#data"]);
},
'internalProjection': proj900913,
'externalProjection': proj4326
}),
readWithPOST: true
})
}),
autoLoad: true,
});
The var obj is always NULL... can you help me please ?
Thanks...
-Pol D.-
http://www.google.com/profiles/110003197662276240659
On Fri, Sep 17, 2010 at 10:15, Pol <d.paolino at gmail.com> wrote:
> It seems that screenshots are not allowed, so I made a link to imageshack
> here:
>
> First: http://img713.imageshack.us/i/screenshot20100917at935.png/
> Second: http://img96.imageshack.us/i/screenshot20100917at936.png/
>
>
> -Pol D.-
> http://www.google.com/profiles/110003197662276240659
>
>
> On Fri, Sep 17, 2010 at 09:40, Pol <d.paolino at gmail.com> wrote:
>
>> 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/20100928/a483d6d2/attachment.htm
More information about the Users
mailing list