[OpenLayers-Users] SelectFeature control/Feature Handler
interaction on programmatic feature selection
Eric Lemoine
eric.c2c at gmail.com
Tue Sep 2 12:06:00 EDT 2008
Justin. Yet, the way you work around the issue is lightweight and
probably leads to better performance that relying on a click handler.
I may well stick it in my code as-is :) cheers. Eric
2008/9/2, Justin Stern <jstern81 at gmail.com>:
> The background: my goal is to make vector features which open a popup
> when clicked, or when their name is clicked in a list. The popup
> should close when the features are 'unselected'. To do this I add a
> SelectFeature control, similar to one of the OpenLayers demo examples,
> and when I want to open the popup programmatically , I invoke the
> 'select' method on the SelectFeature control.
>
> The issue: this works well, except for when the very first action is
> the user clicking the feature name to open the popup. In this case,
> clicking outside the popup (the map area) does not cause the popup to
> close. It must be closed via the 'x' or by clicking that or another
> feature to open a new popup, at which point future programmatically
> opened popups behave the same as those from clicking a feature.
>
> I tracked this down to the Handler not being informed of features
> selected via the control 'select' method (which makes sense, the
> Handler handles mouse events, which calling 'select' is not), which
> causes certain checks to fail in the Handler when the user then clicks
> outside the popup. To the Handler nothing appears to be selected, so
> it doesn't know to tell the feature control to 'unselect' the feature.
>
> Now I seem to be able to work around this issue by faking out the
> Handler when I detect the first programmatic select:
>
> if(!selectFeatureControl.handlers.feature.lastFeature) {
> selectFeatureControl.handlers.feature.lastFeature =
> selectFeatureControl.handlers.feature.feature = theFeature;
> selectFeatureControl.handlers.feature.handled = true;
> }
>
> But it makes me wonder if my approach is wrong to have to go through
> this sort of thing... Any suggestions?
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list