you wanted viewportpx from latlon? well, you got it mister. using a small and but ingenious hack by the astute dr. steven erle, we are able to fix the last remaining (famous last words) kink in the google layer. seems like it should be all a-o-k now. Changed the getLonLatFromViewPortPx() to use the Container as well. Case closed.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@834 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-06-30 01:04:10 +00:00
parent 5524399a3e
commit a02c0ea8b7

View File

@@ -172,7 +172,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var gPoint = this.getGPointFromOLPixel(viewPortPx);
var gLatLng = this.gmap.fromDivPixelToLatLng(gPoint)
var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint)
return this.getOLLonLatFromGLatLng(gLatLng);
},
@@ -187,11 +187,40 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
*/
getViewPortPxFromLonLat: function (lonlat) {
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
var gPoint = this.gmap.fromLatLngToDivPixel(gLatLng)
// note we use special hacked function here,
// because GMaps doesnt give it to us
var gPoint = this.fromLatLngToContainerPixel(gLatLng);
return this.getOLPixelFromGPoint(gPoint);
},
/** 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
*