[OpenLayers-Users] Fixing Google Layers, OL SVN + OL <= 2.4
Christopher Schmidt
crschmidt at metacarta.com
Tue Sep 18 16:50:07 EDT 2007
On Tue, Sep 18, 2007 at 01:46:24PM -0700, samd wrote:
>
> Yes Chris,
>
> I added the change you mentioned to the start of my onload routine before
> the map/layers are created but the JavaScripts are loaded.
Sam:
I'm sorry. The previous code provided was mistaken. The Wiki Page is now
updated to code which will work. Instead of the previous snippet, you
should do:
OpenLayers.Layer.Google.prototype.addContainerPxFunction=function() {
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
// first we translate into "DivPixel"
var gPoint = this.fromLatLngToDivPixel(gLatLng);
// locate the sliding "Div" div
var div = this.getContainer().firstChild.firstChild;
// adjust by the offset of "Div" and voila!
gPoint.x += div.offsetLeft;
gPoint.y += div.offsetTop;
return gPoint;
};
}
};
Please let us know if this does not fix the problem.
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list