[OpenLayers-Users] Bug in select/unselect cluster feature and zoom
in and out?
jkm
rifins at gmail.com
Wed Mar 28 11:04:43 EDT 2012
Hi,
I would like to know if I'm doing something wrong, or not..
I have a cluster strategy associated to a vector layer.. And I select and
unselect features with the "selectCtrl":
selectCtrl = new OpenLayers.Control.SelectFeature(layerTest, { onSelect:
onFeatureSelect, onUnselect: onFeatureUnselect });
map.addControl(selectCtrl);
selectCtrl.activate();
When I select a feature I do:
function onFeatureSelect(feature) {
selectedFeature = feature;
if (currentPopup) currentPopup.hide();
if (!feature.cluster) {
if (!feature.popup) {
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.data.point, null, feature.data.info, null, true, onPopupClose);
feature.popup = popup;
}
else { popup = feature.popup; }
}
else {
var txt = 'Clustered feature';
if (!feature.popup) {
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.cluster[0].data.point, null, txt, null, true, onPopupClose);
feature.popup = popup;
}
else { popup = feature.popup; }
}
map.addPopup(popup);
currentPopup = popup;
}
What I pretend is to show a popup indicating the information of a single
point, or indicate that the point is a cluster of different features.
When I unselect a feature, I do:
function onFeatureUnselect(feature) {
if (currentPopup) {
currentPopup.hide();
}
if (currentPopup = feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
currentPopup = undefined;
}
}
If the feature has an associated popup, I destroy it.
But, if I show a popup for a feature and I zoom in or out making feature
changing (because there are more features clustered, or on the other side,
the cluster doesn't exist anymore), when I unselect the feature, I get an
error in Openlayers.js, in the unhighlight function:
"layer.drawFeature(feature,feature.style||feature.layer.style||"default");"
And this is due to the feature.layer is null...
I don't know if i'm definig something in a bad way, or what is happening
here.. Any help will be apreciated.
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120328/caf2aaaf/attachment-0001.html
More information about the Users
mailing list