bringing all changes from sandbox/euzuro/LayersReworking down into the trunk. this is a merge of r656:HEAD http://svn.openlayers.org/sandbox/euzuro/LayersReworking
git-svn-id: http://svn.openlayers.org/trunk/openlayers@806 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+232
-27
@@ -14,7 +14,7 @@ OpenLayers.Layer.Google = Class.create();
|
||||
OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** @type Boolean */
|
||||
viewPortLayer: true,
|
||||
isFixed: true,
|
||||
|
||||
/** @type GMap2 gmap stores the Google Map element */
|
||||
gmap:null,
|
||||
@@ -27,8 +27,18 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
initialize: function(name) {
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, [name]);
|
||||
initialize: function(name, options) {
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||
|
||||
if (this.minZoomLevel == null) {
|
||||
this.minZoomLevel = -1;
|
||||
}
|
||||
if (this.maxZoomLevel == null) {
|
||||
this.maxZoomLevel = 16;
|
||||
}
|
||||
if (this.maxExtent == null) {
|
||||
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -50,21 +60,29 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {int} zoomChanged
|
||||
* @param {Boolean} zoomChanged
|
||||
*/
|
||||
moveTo:function(bounds,zoomChanged) {
|
||||
moveTo:function(bounds, zoomChanged) {
|
||||
|
||||
if ((this.gmap != null) && (!this.dragging)) {
|
||||
|
||||
var olCenter = this.map.getCenter();
|
||||
var gCenter = this.getGMapCenter();
|
||||
|
||||
var olZoom = this.map.getZoom();
|
||||
var gZoom = this.gmap.getZoom();
|
||||
|
||||
if ((!olCenter.equals(gCenter)) || ((olZoom +1) != gZoom)) {
|
||||
this.gmap.setCenter(new GLatLng(olCenter.lat, olCenter.lon),
|
||||
olZoom + 1);
|
||||
var newCenter = this.map.getCenter();
|
||||
var newZoom = this.map.getZoom();
|
||||
|
||||
if (newCenter != null) {
|
||||
var gCenter = this.gmap.getCenter();
|
||||
var gZoom = this.gmap.getZoom();
|
||||
|
||||
var currentCenter = this.getOLLonLatFromGLatLng(gCenter);
|
||||
var currentZoom = this.getOLZoomFromGZoom(gZoom);
|
||||
|
||||
if ( (!newCenter.equals(currentCenter)) ||
|
||||
(newZoom != currentZoom) ) {
|
||||
|
||||
this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter),
|
||||
this.getGZoomFromOLZoom(newZoom));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -73,6 +91,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
*
|
||||
*/
|
||||
loadGMap:function() {
|
||||
|
||||
// create div and set to same size as map
|
||||
var gDiv = OpenLayers.Util.createDiv(this.name);
|
||||
var sz = this.map.getSize();
|
||||
@@ -82,6 +101,8 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
// create GMap, hide nav controls
|
||||
this.gmap = new GMap2(this.div);
|
||||
|
||||
// this causes the GMap to set itself to Map's center/zoom
|
||||
this.moveTo();
|
||||
|
||||
// catch pans and zooms from GMap
|
||||
@@ -101,6 +122,11 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
"dragend",
|
||||
this.dragEnd.bindAsEventListener(this));
|
||||
|
||||
// catch pans and zooms from GMap
|
||||
GEvent.addListener(this.gmap,
|
||||
"drag",
|
||||
this.catchPanZoom.bindAsEventListener(this));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -123,30 +149,209 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
* @param {event} e
|
||||
*/
|
||||
catchPanZoom: function(e) {
|
||||
var olCenter = this.getGMapCenter();
|
||||
|
||||
var gCenter = this.gmap.getCenter();
|
||||
var gZoom = this.gmap.getZoom();
|
||||
|
||||
this.map.setCenter(olCenter, gZoom - 1);
|
||||
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
|
||||
var olZoom = this.getOLZoomFromGZoom(gZoom);
|
||||
|
||||
this.map.setCenter(olCenter, olZoom);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by GMAPS
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var gPoint = this.getGPointFromOLPixel(viewPortPx);
|
||||
var gLatLng = this.gmap.fromDivPixelToLatLng(gPoint)
|
||||
|
||||
return this.getOLLonLatFromGLatLng(gLatLng);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY GMAPS
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
|
||||
var gPoint = this.gmap.fromLatLngToDivPixel(gLatLng)
|
||||
|
||||
return this.getOLPixelFromGPoint(gPoint);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
|
||||
var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
|
||||
|
||||
return this.getOLZoomFromGZoom(gZoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||
* current viewPort.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getExtent: function () {
|
||||
if (this.gmap.getCenter() == null) {
|
||||
this.moveTo();
|
||||
}
|
||||
var gLatLngBounds = this.gmap.getBounds();
|
||||
return this.getOLBoundsFromGLatLngBounds(gLatLngBounds);
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate GMaps and OL */
|
||||
/* formats for Pixel, LonLat, Bounds, and Zoom */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
//
|
||||
// TRANSLATION: GZoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {int} gZoom
|
||||
*
|
||||
* @returns An OpenLayers.LonLat with the center of the gmap, or null if
|
||||
* the GMap has not been centered yet
|
||||
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
|
||||
* @type int
|
||||
*/
|
||||
getOLZoomFromGZoom: function(gZoom) {
|
||||
return (gZoom - 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} olZoom
|
||||
*
|
||||
* @returns A GZoom level, translated from the passed in olZoom
|
||||
* @type int
|
||||
*/
|
||||
getGZoomFromOLZoom: function(olZoom) {
|
||||
return (olZoom + 1);
|
||||
},
|
||||
|
||||
//
|
||||
// TRANSLATION: GLatLng <-> LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in GLatLng
|
||||
* @type OpenLayers.LonLat
|
||||
*/
|
||||
getGMapCenter:function() {
|
||||
var olCenter = null;
|
||||
var gCenter = this.gmap.getCenter();
|
||||
if (gCenter != null) {
|
||||
olCenter = new OpenLayers.LonLat(gCenter.lng(), gCenter.lat());
|
||||
getOLLonLatFromGLatLng: function(gLatLng) {
|
||||
var olLonLat = null;
|
||||
if (gLatLng != null) {
|
||||
olLonLat = new OpenLayers.LonLat(gLatLng.lng(), gLatLng.lat());
|
||||
}
|
||||
return olCenter;
|
||||
return olLonLat;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
*
|
||||
* @returns A GLatLng, translated from the passed in OpenLayers.LonLat
|
||||
* @type GLatLng
|
||||
*/
|
||||
getGLatLngFromOLLonLat: function(olLonLat) {
|
||||
var gLatLng = null;
|
||||
if (olLonLat != null) {
|
||||
gLatLng = new GLatLng(olLonLat.lat, olLonLat.lon);
|
||||
}
|
||||
return gLatLng;
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: GPoint <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {GPoint} gPoint
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in GPoint
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromGPoint: function(gPoint) {
|
||||
var olPixel = null;
|
||||
if (gPoint != null) {
|
||||
olPixel = new OpenLayers.Pixel(gPoint.x, gPoint.y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns A GPoint, translated from the passed in OpenLayers.Pixel
|
||||
* @type GPoint
|
||||
*/
|
||||
getGPointFromOLPixel: function(olPixel) {
|
||||
var gPoint = null;
|
||||
if (olPixel != null) {
|
||||
gPoint = new GPoint(olPixel.x, olPixel.y);
|
||||
}
|
||||
return gPoint;
|
||||
},
|
||||
|
||||
//
|
||||
// TRANSLATION: GLatLngBounds <-> OpenLayers.Bounds
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {GLatLngBounds} gLatLngBounds
|
||||
*
|
||||
* @returns An OpenLayers.Bounds, translated from gLatLngBounds
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getOLBoundsFromGLatLngBounds: function(gLatLngBounds) {
|
||||
var olBounds = null;
|
||||
if (gLatLngBounds != null) {
|
||||
var sw = gLatLngBounds.getSouthWest();
|
||||
var ne = gLatLngBounds.getNorthEast();
|
||||
olBounds = new OpenLayers.Bounds(sw.lng(),
|
||||
sw.lat(),
|
||||
ne.lng(),
|
||||
ne.lat() );
|
||||
}
|
||||
return olBounds;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} olBounds
|
||||
*
|
||||
* @returns A GLatLngBounds, translated from olBounds
|
||||
* @type GLatLngBounds
|
||||
*/
|
||||
getGLatLngBoundsFromOLBounds: function(olBounds) {
|
||||
var gLatLngBounds = null;
|
||||
if (olBounds != null) {
|
||||
var sw = new GLatLng(olBounds.bottom, olBounds.left);
|
||||
var ne = new GLatLng(olBounds.top, olBounds.right);
|
||||
gLatLngBounds = new GLatLngBounds(sw, ne);
|
||||
}
|
||||
return gLatLngBounds;
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Google"
|
||||
});
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
// @require: OpenLayers/Layer.js
|
||||
// @require: OpenLayers/Util.js
|
||||
OpenLayers.Layer.Grid = Class.create();
|
||||
OpenLayers.Layer.Grid.TILE_WIDTH = 256;
|
||||
OpenLayers.Layer.Grid.TILE_HEIGHT = 256;
|
||||
OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
// str: url
|
||||
@@ -25,17 +23,16 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
* @param {str} name
|
||||
* @param {str} url
|
||||
* @param {hash} params
|
||||
* @param {Object} options Hash of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, url, params) {
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = arguments;
|
||||
if (arguments.length > 0) {
|
||||
newArguments = [name];
|
||||
newArguments = [name, options];
|
||||
}
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
|
||||
this.url = url;
|
||||
this.params = params;
|
||||
this.tileSize = new OpenLayers.Size(OpenLayers.Layer.Grid.TILE_WIDTH,
|
||||
OpenLayers.Layer.Grid.TILE_HEIGHT);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -48,18 +45,33 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** When the layer is added to a map, then we can ask the map for
|
||||
* its default tile size
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||
if (this.tileSize == null) {
|
||||
this.tileSize = this.map.getTileSize();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated User should just set the 'tileSize' via options
|
||||
*/
|
||||
setTileSize: function (size) {
|
||||
this.tileSize = size.copyOf();
|
||||
},
|
||||
|
||||
/**
|
||||
* moveTo
|
||||
* moveTo is a function called whenever the map is moved. All the moving
|
||||
/** This function is called whenever the map is moved. All the moving
|
||||
* of actual 'tiles' is done by the map, but moveTo's role is to accept
|
||||
* a bounds and make sure the data that that bounds requires is pre-loaded.
|
||||
*
|
||||
* @param {OpenLayers.Bounds}
|
||||
* @param {Boolean} zoomChanged
|
||||
*/
|
||||
moveTo:function(bounds,zoomChanged) {
|
||||
moveTo:function(bounds, zoomChanged) {
|
||||
if (!this.getVisibility()) {
|
||||
if (zoomChanged) {
|
||||
this.grid = null;
|
||||
@@ -84,6 +96,8 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getGridBounds:function() {
|
||||
var topLeftTile = this.grid[0][0];
|
||||
var bottomRightTile = this.grid[this.grid.length-1][this.grid[0].length-1];
|
||||
@@ -106,7 +120,7 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
var bounds = this.map.getExtent();
|
||||
var extent = this.map.getFullExtent();
|
||||
var extent = this.map.getMaxExtent();
|
||||
var resolution = this.map.getResolution();
|
||||
var tilelon = resolution*this.tileSize.w;
|
||||
var tilelat = resolution*this.tileSize.h;
|
||||
@@ -236,7 +250,7 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
*/
|
||||
getFullRequestString:function(params) {
|
||||
var requestString = "";
|
||||
this.params.SRS = this.map.projection;
|
||||
this.params.SRS = this.map.getProjection();
|
||||
// concat tile params with layer params and convert to string
|
||||
var allParams = Object.extend(this.params, params);
|
||||
var paramsString = OpenLayers.Util.getParameterString(allParams);
|
||||
|
||||
@@ -17,8 +17,9 @@ OpenLayers.Layer.Markers.prototype =
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Object} options Hash of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name) {
|
||||
initialize: function(name, options) {
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||
this.markers = new Array();
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ OpenLayers.Layer.Text = Class.create();
|
||||
OpenLayers.Layer.Text.prototype =
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** store url of text file
|
||||
/** store url of text file - this should be specified in the "options" hash
|
||||
* @type str */
|
||||
location:null,
|
||||
|
||||
@@ -25,16 +25,18 @@ OpenLayers.Layer.Text.prototype =
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {String} location
|
||||
* @param {Object} options Hash of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, location) {
|
||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name]);
|
||||
this.location = location;
|
||||
initialize: function(name, options) {
|
||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
|
||||
this.features = new Array();
|
||||
new Ajax.Request(location,
|
||||
{ method: 'get', onComplete:this.parseData.bind(this) } );
|
||||
if (this.location != null) {
|
||||
new Ajax.Request(this.location,
|
||||
{ method: 'get', onComplete:this.parseData.bind(this) } );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
@@ -43,7 +45,7 @@ OpenLayers.Layer.Text.prototype =
|
||||
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** WFS layer is never a base class.
|
||||
/** Text layer is never a base class.
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: function() {
|
||||
|
||||
@@ -15,7 +15,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** @type Boolean */
|
||||
viewPortLayer: true,
|
||||
isFixed: true,
|
||||
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
@@ -48,9 +48,9 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {int} zoomChanged
|
||||
* @param {Boolean} zoomChanged
|
||||
*/
|
||||
moveTo:function(bounds,zoomChanged) {
|
||||
moveTo:function(bounds, zoomChanged) {
|
||||
|
||||
if (this.vemap != null) {
|
||||
var olCenter = this.map.getCenter();
|
||||
|
||||
@@ -11,7 +11,10 @@ OpenLayers.Layer.WFS.prototype =
|
||||
Object.extend(new OpenLayers.Layer.Grid(),
|
||||
Object.extend(new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** @type Object */
|
||||
/** Allow the user to specify a special class to use to display features.
|
||||
* This allows for easy-definition of feature behaviour. This property
|
||||
* should be set via the "options" parameter.
|
||||
* @type Object */
|
||||
featureClass: OpenLayers.Feature.WFS,
|
||||
|
||||
/** @final @type hash */
|
||||
@@ -27,16 +30,14 @@ OpenLayers.Layer.WFS.prototype =
|
||||
* @param {str} name
|
||||
* @param {str} url
|
||||
* @param {hash} params
|
||||
* @param {Object} featureClass
|
||||
* @param {Object} options Hash of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, url, params, featureClass) {
|
||||
if (featureClass != null) this.featureClass = featureClass;
|
||||
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = new Array();
|
||||
if (arguments.length > 0) {
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params);
|
||||
newArguments.push(name, url, params, options);
|
||||
}
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
@@ -24,16 +24,17 @@ OpenLayers.Layer.WMS.prototype =
|
||||
* @param {str} name
|
||||
* @param {str} url
|
||||
* @param {hash} params
|
||||
* @param {Object} options Hash of extra options to tag onto the layer
|
||||
*/
|
||||
initialize: function(name, url, params) {
|
||||
initialize: function(name, url, params, options) {
|
||||
var newArguments = new Array();
|
||||
if (arguments.length > 0) {
|
||||
//uppercase params
|
||||
params = OpenLayers.Util.upperCaseObject(params);
|
||||
newArguments.push(name, url, params);
|
||||
newArguments.push(name, url, params, options);
|
||||
}
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
@@ -43,7 +44,7 @@ OpenLayers.Layer.WMS.prototype =
|
||||
},
|
||||
|
||||
|
||||
/** WFS layer is never a base class.
|
||||
/** WMS layer is never a base class.
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: function() {
|
||||
@@ -86,6 +87,49 @@ OpenLayers.Layer.WMS.prototype =
|
||||
url, this.tileSize);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @returns Degrees per Pixel
|
||||
* @type float
|
||||
*/
|
||||
getResolution: function() {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var zoom = this.map.getZoom();
|
||||
|
||||
return maxRes / Math.pow(2, zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
var maxZoomLevel = this.map.getMaxZoomLevel();
|
||||
var minZoomLevel = this.map.getMinZoomLevel();
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, minZoomLevel),
|
||||
maxZoomLevel );
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.WMS"
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ OpenLayers.Layer.Yahoo = Class.create();
|
||||
OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** @type Boolean */
|
||||
viewPortLayer: true,
|
||||
isFixed: true,
|
||||
|
||||
/** @type GMap2 gmap stores the Google Map element */
|
||||
ymap:null,
|
||||
@@ -49,9 +49,9 @@ OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {int} zoomChanged
|
||||
* @param {Boolean} zoomChanged
|
||||
*/
|
||||
moveTo:function(bounds,zoomChanged) {
|
||||
moveTo:function(bounds, zoomChanged) {
|
||||
|
||||
if ((this.ymap != null) && (!this.dragging)) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user