[OpenLayers-Users] textlayer: popups with closebox

kmalk kmalkowski at sourcepark.de
Fri Aug 28 06:51:01 EDT 2009


By the way: If anyone wants the soultion for the post-question:

add anchoredBubbleClass to textLayer for closeBehavior without
changing html popup structure and showing only one popup at once


OpenLayers.Feature.prototype.popupClass = OpenLayers.Popup.AnchoredBubble;
OpenLayers.Layer.Text.prototype.markerClick = function(evt) {
var sameMarkerClicked = (this == this.layer.selectedFeature);

//does popups [OL array] exist AND was another marker clicked?
if(this.popup==null && !sameMarkerClicked 
   && this.layer.map.popups && this.layer.map.popups.length > 0){
  for (var i=0; i < this.layer.map.popups.length; i++) {
    //yes - remove all popups [OL popup]
    this.layer.map.removePopup(this.layer.map.popups[i]);
  }//end for i
}//end if popup(s) AND marker 

//does popup exist?
if (this.popup) {
    this.popup.toggle();                  //yes - toggle it
} else {
    var myPopup = this.createPopup(true); //no - create one with closeButton
    this.layer.map.addPopup(myPopup);     //and add it to map
}//end if else this.popup

this.layer.selectedFeature = (!sameMarkerClicked) ? this : null;
OpenLayers.Event.stop(evt);
}//end markerClick


-- 
View this message in context: http://n2.nabble.com/textlayer-popups-with-closebox-tp2311841p3533940.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090828/1aa1a3d5/attachment.html


More information about the Users mailing list