[OpenLayers-Dev] Re: How do I fire a function after all features
have been selected by a box in OpenLayers?
Xavier Mamano (jorix)
xavier.mamano at gmail.com
Mon Jan 9 16:48:01 EST 2012
Hi,
I have worked on something similar, and I ended up creating a
OpenLayers.Handler.Box outside the OpenLayers.Control.SelectFeature and also
call outside the routine "selectBox" from "SelectFeature"
See line 198 in this code:
https://github.com/jorix/OL-FeaturePopups/blob/gh-pages/lib/FeaturePopups.js#L198
and "done" callback in line 527.
You can test it in:
http://jorix.github.com/OL-FeaturePopups/examples/feature-popups.html
--press CTRL key while dragging--
Sorry the code has many other things that perhaps prevent you from an easy
to read. Feel free to ask.
Xavier Mamano
brianwmunz wrote
>
> I have a map rendering with Polygons on a Vector layer set up as features.
> I set up the features so they fire off a function when the feature is
> selected and this works fine. The issue I'm having is when I try to allow
> users to select multiple features using a box. This causes the function to
> fire for each feature that is selected. I understand why this is, but what
> I really need is to have a function that fires once all of the features
> are selected so I can run a function using all selected features instead
> of having it run once for each. Here is my selectFeature code:
>
> window[mapName].addControl(control);
> control.activate();
> var selectCtrl = new
> OpenLayers.Control.SelectFeature(layerVector, {
> clickout: true,
> onSelect: onFeatureSelect,
> onUnselect: onFeatureUnselect,
> box: true
> });
> window[mapName].addControl(selectCtrl);
> selectCtrl.activate();
> }
> });
>
> It looks like there's away to attach Handlers to Boxes but so far I've
> been unsuccessful. Also, I'm afraid that if the function runs after the
> box selection is finished, it might not be getting the full list of
> selectedFeatures.
>
> Any help would be GREATLY appreciated. Thanks
>
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-do-I-fire-a-function-after-all-features-have-been-selected-by-a-box-in-OpenLayers-tp7168754p7169708.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev
mailing list