add code to Map.js to allow for the addittion and removal of popups. add a new html file to play around with popups. add a test in the test_Map file for the popup adding/removing

git-svn-id: http://svn.openlayers.org/trunk/openlayers@227 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-21 15:47:10 +00:00
parent b5c6bbbf20
commit d9762c984e
3 changed files with 114 additions and 0 deletions

View File

@@ -42,6 +42,9 @@ OpenLayers.Map.prototype = {
// Array(OpenLayers.Control)
controls: null,
// Array(OpenLayers.Popup)
popups: null,
// OpenLayers.LonLat
center: null,
@@ -85,6 +88,8 @@ OpenLayers.Map.prototype = {
this.addControl( new OpenLayers.Control.PanZoom() );
this.addControl( new OpenLayers.Control.MouseDefaults() );
this.popups = new Array();
// always call map.destroy()
Event.observe(window, 'unload',
this.destroy.bindAsEventListener(this));
@@ -142,6 +147,28 @@ OpenLayers.Map.prototype = {
}
},
/**
* @param {OpenLayers.Popup} popup
*/
addPopup: function(popup) {
popup.map = this;
this.popups.push(popup);
var popupDiv = popup.draw();
if (popupDiv) {
popupDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] +
this.popups.length;
this.viewPortDiv.appendChild(popupDiv);
}
},
/**
* @param {OpenLayers.Popup} popup
*/
removePopup: function(popup) {
this.popups.remove(popup);
this.viewPortDiv.removeChild(popup.div);
},
/**
* @return {float}
*/