Merge 2.0 branch to trunk.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1369 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+62
-95
@@ -78,33 +78,38 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
// Options
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
|
||||
/** @type String */
|
||||
projection: "EPSG:4326",
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
maxExtent: null,
|
||||
|
||||
/** @type String */
|
||||
units: 'degrees',
|
||||
|
||||
/** default max is 360 deg / 256 px, which corresponds to
|
||||
* zoom level 0 on gmaps
|
||||
*
|
||||
* @type float */
|
||||
maxResolution: 1.40625,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
/** @type float */
|
||||
minResolution: null,
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
/** @type float */
|
||||
maxScale: null,
|
||||
|
||||
/** @type String */
|
||||
units: 'degrees',
|
||||
|
||||
/** @type Float */
|
||||
/** @type float */
|
||||
minScale: null,
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
maxExtent: null,
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
minExtent: null,
|
||||
|
||||
/** @type int */
|
||||
numZoomLevels: 16,
|
||||
|
||||
|
||||
/**
|
||||
@@ -129,6 +134,8 @@ OpenLayers.Map.prototype = {
|
||||
// the layerContainerDiv is the one that holds all the layers
|
||||
id = div.id + "_OpenLayers_Container";
|
||||
this.layerContainerDiv = OpenLayers.Util.createDiv(id);
|
||||
this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
|
||||
|
||||
this.viewPortDiv.appendChild(this.layerContainerDiv);
|
||||
|
||||
this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
|
||||
@@ -148,7 +155,7 @@ OpenLayers.Map.prototype = {
|
||||
Event.observe(window, 'resize',
|
||||
this.updateSize.bindAsEventListener(this));
|
||||
}
|
||||
|
||||
|
||||
//set the default options
|
||||
this.setOptions(options);
|
||||
|
||||
@@ -207,16 +214,6 @@ OpenLayers.Map.prototype = {
|
||||
// now add the options declared by the user
|
||||
// (these will override defaults)
|
||||
Object.extend(this, options);
|
||||
|
||||
// if maxResolution is specified as "auto", calculate it
|
||||
// based on the maxExtent and the viewSize
|
||||
//
|
||||
if (this.maxResolution == "auto" || this.maxResolution == null) {
|
||||
var maxExtent = this.getMaxExtent();
|
||||
var viewSize = this.getSize();
|
||||
this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w,
|
||||
maxExtent.getHeight() / viewSize.h );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -374,9 +371,12 @@ OpenLayers.Map.prototype = {
|
||||
if (center != null) {
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
if (zoom > this.baseLayer.numZoomLevels - 1) {
|
||||
zoom = this.baseLayer.numZoomLevels - 1;
|
||||
}
|
||||
this.setCenter(center, zoom);
|
||||
|
||||
}
|
||||
|
||||
if ((noEvent == null) || (noEvent == false)) {
|
||||
this.events.triggerEvent("changebaselayer");
|
||||
}
|
||||
@@ -470,14 +470,18 @@ OpenLayers.Map.prototype = {
|
||||
if (oldSize == null)
|
||||
this.size = oldSize = newSize;
|
||||
if (!newSize.equals(oldSize)) {
|
||||
// move the layer container so that the map is still centered
|
||||
var dx = (newSize.w - oldSize.w) / 2,
|
||||
dy = (newSize.h - oldSize.h) / 2;
|
||||
var lcStyle = this.layerContainerDiv.style;
|
||||
lcStyle.left = (parseInt(lcStyle.left) + dx) + "px";
|
||||
lcStyle.top = (parseInt(lcStyle.top ) + dy) + "px";
|
||||
// reset the map center
|
||||
this.layerContainerOrigin = this.center.clone();
|
||||
|
||||
//notify layers of mapresize
|
||||
for(var i=0; i < this.layers.length; i++) {
|
||||
this.layers[i].onMapResize();
|
||||
}
|
||||
|
||||
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
|
||||
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
this.setCenter(center, zoom);
|
||||
|
||||
// store the new size
|
||||
this.size = newSize;
|
||||
// the div might have moved on the page, also
|
||||
@@ -561,7 +565,6 @@ OpenLayers.Map.prototype = {
|
||||
* trigger movestart/end events
|
||||
*/
|
||||
setCenter: function (lonlat, zoom, minor) {
|
||||
|
||||
var zoomChanged = (this.isValidZoomLevel(zoom)) &&
|
||||
(zoom != this.getZoom());
|
||||
|
||||
@@ -598,7 +601,7 @@ OpenLayers.Map.prototype = {
|
||||
this.popups[i].updatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//send the move call to the baselayer and all the overlays
|
||||
var bounds = this.getExtent();
|
||||
for (var i = 0; i < this.layers.length; i++) {
|
||||
@@ -643,8 +646,8 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
isValidZoomLevel: function(zoomLevel) {
|
||||
return ( (zoomLevel != null) &&
|
||||
(zoomLevel >= this.getMinZoomLevel()) &&
|
||||
(zoomLevel <= this.getMaxZoomLevel()) );
|
||||
(zoomLevel >= 0) &&
|
||||
(zoomLevel < this.getNumZoomLevels()) );
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -680,15 +683,9 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getProjection: function() {
|
||||
var projection = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
projection = this.baseLayer.getProjection();
|
||||
}
|
||||
|
||||
if (projection == null) {
|
||||
projection = this.projection;
|
||||
}
|
||||
|
||||
return projection;
|
||||
},
|
||||
|
||||
@@ -698,15 +695,9 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getMaxResolution: function() {
|
||||
var maxResolution = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
maxResolution = this.baseLayer.getMaxResolution();
|
||||
}
|
||||
|
||||
if (maxResolution == null) {
|
||||
maxResolution = this.maxResolution;
|
||||
}
|
||||
|
||||
return maxResolution;
|
||||
},
|
||||
|
||||
@@ -715,55 +706,25 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getMaxExtent: function () {
|
||||
var maxExtent = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
maxExtent = this.baseLayer.getMaxExtent();
|
||||
}
|
||||
|
||||
if (maxExtent == null) {
|
||||
maxExtent = this.maxExtent;
|
||||
}
|
||||
|
||||
}
|
||||
return maxExtent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The maximum zoom level that can be reached in the map
|
||||
* @returns The total number of zoom levels that can be displayed by the
|
||||
* current baseLayer.
|
||||
* @type int
|
||||
*/
|
||||
getMaxZoomLevel: function() {
|
||||
var maxZoomLevel = null;
|
||||
|
||||
getNumZoomLevels: function() {
|
||||
var numZoomLevels = null;
|
||||
if (this.baseLayer != null) {
|
||||
maxZoomLevel = this.baseLayer.getMaxZoomLevel();
|
||||
numZoomLevels = this.baseLayer.getNumZoomLevels();
|
||||
}
|
||||
|
||||
if (maxZoomLevel == null) {
|
||||
maxZoomLevel = this.maxZoomLevel;
|
||||
}
|
||||
|
||||
return maxZoomLevel;
|
||||
return numZoomLevels;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The minimum zoom level that can be reached in the map
|
||||
* @type int
|
||||
*/
|
||||
getMinZoomLevel: function() {
|
||||
var minZoomLevel = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
minZoomLevel = this.baseLayer.getMinZoomLevel();
|
||||
}
|
||||
|
||||
if (minZoomLevel == null) {
|
||||
minZoomLevel = this.minZoomLevel;
|
||||
}
|
||||
|
||||
return minZoomLevel;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
@@ -783,7 +744,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
extent = this.baseLayer.getExtent();
|
||||
}
|
||||
@@ -797,7 +757,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getResolution: function () {
|
||||
var resolution = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
resolution = this.baseLayer.getResolution();
|
||||
}
|
||||
@@ -811,9 +770,8 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getScale: function () {
|
||||
var scale = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
var res = this.baseLayer.getResolution();
|
||||
var res = this.getResolution();
|
||||
var units = this.baseLayer.units;
|
||||
scale = res * OpenLayers.INCHES_PER_UNIT[units] *
|
||||
OpenLayers.DOTS_PER_INCH;
|
||||
@@ -831,7 +789,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
zoom = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
zoom = this.baseLayer.getZoomForExtent(bounds);
|
||||
}
|
||||
@@ -853,7 +810,9 @@ OpenLayers.Map.prototype = {
|
||||
* @param {int} zoom
|
||||
*/
|
||||
zoomTo: function(zoom) {
|
||||
this.setCenter(null, zoom);
|
||||
if (this.isValidZoomLevel(zoom)) {
|
||||
this.setCenter(null, zoom);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -927,7 +886,11 @@ OpenLayers.Map.prototype = {
|
||||
* @private
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
return this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
|
||||
var lonlat = null;
|
||||
if (this.baseLayer != null) {
|
||||
lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -940,7 +903,11 @@ OpenLayers.Map.prototype = {
|
||||
* @private
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
return this.baseLayer.getViewPortPxFromLonLat(lonlat);
|
||||
var px = null;
|
||||
if (this.baseLayer != null) {
|
||||
px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
|
||||
}
|
||||
return px;
|
||||
},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user