[OpenLayers-Dev] Re: Possible bug with Protocol.HTTP

Eric Lemoine eric.lemoine at camptocamp.com
Wed Jun 15 00:46:18 EDT 2011


On Tue, Jun 14, 2011 at 11:56 PM, codydjango <codydjango at gmail.com> wrote:
>
> In this case your callback isn't called because of the Fixed strategy.
>> The strategy calls protocol.read and provides its own callback to the
>> read method, so this overrides the "global" callback. If your app code
>> does protocol.read() somewhere then your "global" callback func will
>> get invoked.
>
> Hello -- I'm new to openlayers, and I've been running into some issues,
> probably because I'm new.  One of the first things I wanted to do was draw a
> box, have the server return all the features in the box, and then "do
> something" with them.
>
> I thought I'd use something like this:
>
>        var getFeatures = new OpenLayers.Control.GetFeature({
>            box: true,
>            click: false,
>            multiple: true,
>            protocol: new OpenLayers.Protocol.HTTP({
>                url: '/obj',
>                format: new OpenLayers.Format.GeoJSON(),
>                params: {
>                    limit: 2000
>                }
>            })
>        });
>
> What is the best way to set a custom callback to go off once their is
> response data to work with?

The control triggers "featuresselected" events when features are received.

        var getFeatures = new OpenLayers.Control.GetFeature({
            box: true,
            click: false,
            multiple: true,
            protocol: new OpenLayers.Protocol.HTTP({
                url: '/obj',
                format: new OpenLayers.Format.GeoJSON(),
                params: {
                    limit: 2000
                }
            }),
            eventListeners: {
                featuresselected: function(e) {
                    // do something with e.features
                }
            }
        });


-- 
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


More information about the Dev mailing list