With review from elem, and oversight from tschaub, rolling in
SphericalMercator changes. Note that this explicitly does *not* include r4182 , so as to keep changes to a single logical set: that should be filed in a seperate bug if it can be reproduced against trunk after this commit. Hooray for Tim, thanks for all the feedback, onward and upward! (Closes #686) git-svn-id: http://svn.openlayers.org/trunk/openlayers@4221 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -4,17 +4,20 @@
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Layer/SphericalMercator.js
|
||||
* @requires OpenLayers/Layer/EventPane.js
|
||||
* @requires OpenLayers/Layer/FixedZoomLevels.js
|
||||
*
|
||||
* Class: OpenLayers.Layer.Google
|
||||
*
|
||||
* Inherits:
|
||||
* - <OpenLayers.Layer.SphericalMercator>
|
||||
* - <OpenLayers.Layer.EventPane>
|
||||
* - <OpenLayers.Layer.FixedZoomLevels>
|
||||
*/
|
||||
OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
OpenLayers.Layer.Google = OpenLayers.Class(
|
||||
OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
|
||||
/**
|
||||
* Constant: MIN_ZOOM_LEVEL
|
||||
@@ -62,6 +65,14 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
*/
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* APIProperty: sphericalMercator
|
||||
* {Boolean} Should the map act as a mercator-projected map? This will
|
||||
* cause all interactions with the map to be in the actual map projection,
|
||||
* which allows support for vector drawing, overlaying other maps, etc.
|
||||
*/
|
||||
sphericalMercator: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.Google
|
||||
*
|
||||
@@ -74,6 +85,10 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
this.addContainerPxFunction();
|
||||
if (this.sphericalMercator) {
|
||||
OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
|
||||
this.initMercatorParameters();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -151,7 +166,6 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
this.mapObject.checkResize();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: getZoomForExtent
|
||||
*
|
||||
@@ -199,10 +213,17 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
if (moBounds != null) {
|
||||
var sw = moBounds.getSouthWest();
|
||||
var ne = moBounds.getNorthEast();
|
||||
olBounds = new OpenLayers.Bounds(sw.lng(),
|
||||
sw.lat(),
|
||||
ne.lng(),
|
||||
ne.lat() );
|
||||
if (this.sphericalMercator) {
|
||||
sw = this.forwardMercator(sw.lng(), sw.lat());
|
||||
ne = this.forwardMercator(ne.lng(), ne.lat());
|
||||
} else {
|
||||
sw = new OpenLayers.LonLat(sw.lng(), sw.lat());
|
||||
ne = new OpenLayers.LonLat(ne.lng(), ne.lat());
|
||||
}
|
||||
olBounds = new OpenLayers.Bounds(sw.lon,
|
||||
sw.lat,
|
||||
ne.lon,
|
||||
ne.lat );
|
||||
}
|
||||
return olBounds;
|
||||
},
|
||||
@@ -220,16 +241,17 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
getMapObjectBoundsFromOLBounds: function(olBounds) {
|
||||
var moBounds = null;
|
||||
if (olBounds != null) {
|
||||
var sw = new GLatLng(olBounds.bottom, olBounds.left);
|
||||
var ne = new GLatLng(olBounds.top, olBounds.right);
|
||||
moBounds = new GLatLngBounds(sw, ne);
|
||||
var sw = this.sphericalMercator ?
|
||||
this.inverseMercator(olBounds.bottom, olBounds.left) :
|
||||
new OpenLayers.LonLat(olBounds.bottom, olBounds.left);
|
||||
var ne = this.sphericalMercator ?
|
||||
this.inverseMercator(olBounds.top, olBounds.right) :
|
||||
new OpenLayers.LonLat(olBounds.top, olBounds.right);
|
||||
moBounds = new GLatLngBounds(new GLatLng(sw.lat, sw.lon),
|
||||
new GLatLng(ne.lat, ne.lon));
|
||||
}
|
||||
return moBounds;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method: addContainerPxFunction
|
||||
@@ -396,7 +418,9 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
* {Float} Longitude of the given MapObject LonLat
|
||||
*/
|
||||
getLongitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.lng();
|
||||
return this.sphericalMercator ?
|
||||
this.forwardMercator(moLonLat.lng(), moLonLat.lat()).lon :
|
||||
moLonLat.lng();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -409,7 +433,10 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
* {Float} Latitude of the given MapObject LonLat
|
||||
*/
|
||||
getLatitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.lat();
|
||||
var lat = this.sphericalMercator ?
|
||||
this.forwardMercator(moLonLat.lng(), moLonLat.lat()).lat :
|
||||
moLonLat.lat();
|
||||
return lat;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -423,7 +450,14 @@ OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane,
|
||||
* {Object} MapObject LonLat built from lon and lat params
|
||||
*/
|
||||
getMapObjectLonLatFromLonLat: function(lon, lat) {
|
||||
return new GLatLng(lat, lon);
|
||||
var gLatLng;
|
||||
if(this.sphericalMercator) {
|
||||
var lonlat = this.inverseMercator(lon, lat);
|
||||
gLatLng = new GLatLng(lonlat.lat, lonlat.lon);
|
||||
} else {
|
||||
gLatLng = new GLatLng(lat, lon);
|
||||
}
|
||||
return gLatLng;
|
||||
},
|
||||
|
||||
// Pixel
|
||||
|
||||
Reference in New Issue
Block a user