On Wed, Sep 15, 2010 at 8:21 AM, Pol <[email protected]> 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 : [email protected]
http://www.camptocamp.com
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users