Laid in some calls to various application events in Map; also, refactored zoomIn and zoomOut to use zoomTo underlyingly.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@65 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Schuyler Erle
2006-05-16 23:17:44 +00:00
parent 0b596a94f4
commit c494b8ef2d

View File

@@ -65,6 +65,7 @@ OpenLayers.Map.prototype = {
this.div = div = $(div);
// the viewPortDiv is the outermost div we modify
this.viewPortDiv = OpenLayers.Util.createDiv(
div.id + "_OpenLayers_ViewPort" );
this.viewPortDiv.style.width = "100%";
@@ -73,11 +74,13 @@ OpenLayers.Map.prototype = {
this.viewPortDiv.style.position = "relative";
this.div.appendChild(this.viewPortDiv);
// the controlDiv is the div that all the controls sit on
this.controlDiv = OpenLayers.Util.createDiv(
div.id + "_OpenLayers_Control" );
this.controlDiv.style.zIndex = this.Z_INDEX_BASE["Control"];
this.viewPortDiv.appendChild(this.controlDiv);
// the layerContainerDiv is the one that holds all the layers
this.layerContainerDiv = OpenLayers.Util.createDiv(
div.id + "_OpenLayers_Container" );
this.viewPortDiv.appendChild(this.layerContainerDiv);
@@ -121,6 +124,7 @@ OpenLayers.Map.prototype = {
layer.div.style.zIndex = this.Z_INDEX_BASE['Layer'] + this.layers.length;
this.layerContainerDiv.appendChild(layer.div);
this.layers.push(layer);
this.events.triggerEvent("addlayer");
},
/**
@@ -244,11 +248,13 @@ OpenLayers.Map.prototype = {
this.zoom = zoom;
}
this.events.triggerEvent("movestart");
this.moveToNewExtent(zoomChanged);
this.events.triggerEvent("moveend");
},
moveToNewExtent: function (zoomChanged) {
if (zoomChanged) {
if (zoomChanged) { // reset the layerContainerDiv's location
this.layerContainerDiv.style.left = "0px";
this.layerContainerDiv.style.top = "0px";
}
@@ -256,6 +262,9 @@ OpenLayers.Map.prototype = {
for (var i = 0; i < this.layers.length; i++) {
this.layers[i].moveTo(bounds, zoomChanged);
}
this.events.triggerEvent("move");
if (zoomChanged)
this.events.triggerEvent("zoomend");
},
/**
@@ -264,8 +273,7 @@ OpenLayers.Map.prototype = {
*/
zoomIn: function() {
if (this.zoom != null && this.zoom <= this.getZoomLevels()) {
this.zoom += 1;
this.moveToNewExtent(true);
this.zoomTo( this.zoom += 1 );
}
},
@@ -276,8 +284,10 @@ OpenLayers.Map.prototype = {
*/
zoomTo: function(zoom) {
if (zoom >= 0 && zoom <= this.getZoomLevels()) {
var oldZoom = this.zoom;
this.zoom = zoom;
this.moveToNewExtent(true);
this.events.triggerEvent("zoomend", {oldZoom: oldZoom, newZoom: this.zoom});
}
},
@@ -287,8 +297,7 @@ OpenLayers.Map.prototype = {
*/
zoomOut: function() {
if (this.zoom != null && this.zoom > 0) {
this.zoom -= 1;
this.moveToNewExtent(true);
this.zoomTo( this.zoom - 1 );
}
},