[OpenLayers-Users] How to use script protocol callback

Hieronymus jb at thunderbuild.com
Thu Dec 27 01:09:54 PST 2012


I'd like make use of the callback function

http://dev.openlayers.org/docs/files/OpenLayers/Protocol/Script-js.html#OpenLayers.Protocol.Script.callback
<http://dev.openlayers.org/docs/files/OpenLayers/Protocol/Script-js.html#OpenLayers.Protocol.Script.callback
>  

to intercept the server response and modify it based on the current state of
the map (due to user interactions) If I understand it correctly, that
function should get the 'raw' response of the server. But for now it just
doesn't do anything.

I want this function to test if individual features returned by the server
are also on my drawing layer (if a user is modifying one) So I don't get
duplicates on the map.

this.layer = new OpenLayers.Layer.Vector("POI",{
        strategies: [
            new OpenLayers.Strategy.BBOX({
                resFactor: 2,
                active: false,
                autoActivate: false,
                ratio: 1.3,
                noAbort: true
            }), 
            new OpenLayers.Strategy.Cluster({
                distance: this.clusterDistance,
                threshold: this.clusterThreshold
            })
        ],
        protocol: new OpenLayers.Protocol.Script({
            url: 'http://localhost/tests/poi',
            callback: tbPoi.myOwnCallback,
            callbackKey: 'callback',
            format: new OpenLayers.Format.GeoJSON(in_options),
            params: {
                poi: tbPoi.getPoi, // bolean
                geozone: tbPoi.getGeozone //bolean
            }
        }),
        styleMap: new OpenLayers.StyleMap({
            "default": style,
            "vertex": tbMap.vertexStyle
        }, {extendDefault: false})
    });

myOwnCallback: function(data){
    console.log(data);
},

I hope you can help.



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-use-script-protocol-callback-tp5024701.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list