give popups a 'closeOnMove' option. if set to true, the popup will close itself as soon as the map is pan/zoom (move)ed. patch by jrf, euzuro review by elemoine, cr5. (Closes #1726)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8397 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2008-11-19 15:51:18 +00:00
parent d5950d4b29
commit 05cd192ba3
3 changed files with 42 additions and 1 deletions

View File

@@ -173,6 +173,13 @@ OpenLayers.Popup = OpenLayers.Class({
* Default is false.
*/
panMapIfOutOfView: false,
/**
* APIProperty: closeOnMove
* {Boolean} When map pans, close the popup.
* Default is false.
*/
closeOnMove: false,
/**
* Property: map
@@ -253,6 +260,10 @@ OpenLayers.Popup = OpenLayers.Class({
this.opacity = null;
this.border = null;
if (this.closeOnMove && this.map) {
this.map.events.unregister("movestart", this, this.hide);
}
this.events.destroy();
this.events = null;
@@ -294,6 +305,12 @@ OpenLayers.Popup = OpenLayers.Class({
px = this.map.getLayerPxFromLonLat(this.lonlat);
}
}
// this assumes that this.map already exists, which is okay because
// this.draw is only called once the popup has been added to the map.
if (this.closeOnMove) {
this.map.events.register("movestart", this, this.hide);
}
//listen to movestart, moveend to disable overflow (FF bug)
if (OpenLayers.Util.getBrowserName() == 'firefox') {