tag fromLatLngToContainerPixel() function directly onto the GMap2 object. Cleaner code. Easier to distinguish where the hack is, and it is not completely separate of any OL code.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@911 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,8 +1,36 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
// @require: OpenLayers/Layer.js
|
||||
|
||||
|
||||
if (typeof GMap2 != "undefined") {
|
||||
|
||||
/** Hack-on function because GMAPS does not give it to us
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container" coords
|
||||
* @type GPoint
|
||||
*/
|
||||
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
|
||||
|
||||
// first we translate into "DivPixel"
|
||||
var gPoint = this.fromLatLngToDivPixel(gLatLng);
|
||||
|
||||
// locate the sliding "Div" div
|
||||
// it seems like "b" is the main div
|
||||
var div = this.b.firstChild.firstChild;
|
||||
|
||||
// adjust by the offset of "Div" and voila!
|
||||
gPoint.x += div.offsetLeft;
|
||||
gPoint.y += div.offsetTop;
|
||||
|
||||
return gPoint;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
@@ -188,40 +216,14 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||
if (this.gmap != null) {
|
||||
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
|
||||
|
||||
// note we use special hacked function here,
|
||||
// because GMaps doesnt give it to us
|
||||
var gPoint = this.fromLatLngToContainerPixel(gLatLng);
|
||||
// note we use special hacked function here
|
||||
var gPoint = this.gmap.fromLatLngToContainerPixel(gLatLng);
|
||||
|
||||
viewPortPx = this.getOLPixelFromGPoint(gPoint);
|
||||
}
|
||||
return viewPortPx;
|
||||
},
|
||||
|
||||
/** Hacked function because GMAPS does not give us
|
||||
* a fromLatLngToContainerPixel. Cheers sde for the
|
||||
* firstChild.firstChild find.
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container"
|
||||
* coordinates
|
||||
* @type GPoint
|
||||
*/
|
||||
fromLatLngToContainerPixel: function(gLatLng) {
|
||||
|
||||
// first we translate into "DivPixel"
|
||||
var gPoint = this.gmap.fromLatLngToDivPixel(gLatLng);
|
||||
|
||||
// locate the sliding "Div" div
|
||||
var div = this.div.firstChild.firstChild;
|
||||
|
||||
// adjust by the offset of "Div" and voila!
|
||||
gPoint.x += div.offsetLeft;
|
||||
gPoint.y += div.offsetTop;
|
||||
|
||||
return gPoint;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
|
||||
Reference in New Issue
Block a user