Hi Puneet,

You can overwrite the read function of the format. 
Then you should be able to grab the geojson from your response.


//function read from OpenLayers-2.11\lib\OpenLayers\Format\GeoJSON.js
function myReadFunction(json, type, filter)
{
    type = (type) ? type : "FeatureCollection";
    var results = null;

    //instead
    /*
    if (typeof json == "string") {
        obj = OpenLayers.Format.JSON.prototype.read.apply(this,
                                                          [json, filter]);
    } else { 
        obj = json;
    } 
    */   

    //try this
    var obj = eval('(' + json + ')').result.geojson;

    //above no changes
    if(!obj) {
        OpenLayers.Console.error("Bad JSON: " + json);
    } else if(typeof(obj.type) != "string") {
        OpenLayers.Console.error("Bad GeoJSON - no type: " + json);
    }
    else if(this.isValidType(obj, type)) {
...
...
            break;
        }
    }
    return results;
}

var vec = new OpenLayers.Layer.Vector(
        "My Vector Layer", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.HTTP({
            url: "some_features.geojson",
            params: {
                                "a": "value of a",
                                "b": function() {
                                        return a_value_for_b;
                                }
            format: new OpenLayers.Format.GeoJSON({read:myReadFunction})
        })
    }
);

map.addLayer(vec);

Arnd

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to