[OpenLayers-Users] Fixing Google Layers, OL SVN + OL <= 2.4

Samuel Doyle sdoyle_2 at yahoo.com
Tue Sep 18 16:52:57 EDT 2007


Alright Chris,

I'll give that try.

S.D.

----- Original Message ----
From: Christopher Schmidt <crschmidt at metacarta.com>
To: samd <sdoyle_2 at yahoo.com>
Cc: users at openlayers.org
Sent: Tuesday, September 18, 2007 1:50:07 PM
Subject: Re: [OpenLayers-Users] Fixing Google Layers, OL SVN + OL <= 2.4

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




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070918/2bd02e1a/attachment.html


More information about the Users mailing list