OpenLayers OpenLayers

Changeset 1321

Show
Ignore:
Timestamp:
08/21/06 14:34:15 (2 years ago)
Author:
crschmidt
Message:

If Google fails to load before OpenLayers, occasionally dragging is not
possible with Google, because GMap2 would be undefined when the Google
class is included. So, we put this in a wrapper function, and call it
when you init the layer instead.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.0/lib/OpenLayers/Layer/Google.js

    r1308 r1321  
    33 * text of the license. */ 
    44 
    5 if (typeof GMap2 != "undefined") { 
    6      
    7     /** Hack-on function because GMAPS does not give it to us 
    8      *  
    9      * @param {GLatLng} gLatLng  
    10      * 
    11      * @returns A GPoint specifying gLatLng translated into "Container" coords 
    12      * @type GPoint 
    13      */ 
    14     GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) { 
    15      
    16         // first we translate into "DivPixel" 
    17         var gPoint = this.fromLatLngToDivPixel(gLatLng); 
    18      
    19         // locate the sliding "Div" div 
    20         //  it seems like "b" is the main div 
    21         var div = this.b.firstChild.firstChild; 
    22      
    23         // adjust by the offset of "Div" and voila! 
    24         gPoint.x += div.offsetLeft; 
    25         gPoint.y += div.offsetTop; 
    26      
    27         return gPoint; 
    28     }; 
    29 
     5 
     6 
    307 
    318/** 
     
    6643            this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90); 
    6744        } 
    68          
     45        this.addContainerPxFunction();       
    6946        this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1; 
    7047    }, 
     
    432409        return gLatLngBounds; 
    433410    }, 
    434  
    435  
     411     
     412    addContainerPxFunction: function() { 
     413      if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) { 
     414           
     415          /** Hack-on function because GMAPS does not give it to us 
     416           *  
     417           * @param {GLatLng} gLatLng  
     418           * 
     419           * @returns A GPoint specifying gLatLng translated into "Container" coords 
     420           * @type GPoint 
     421           */ 
     422          GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) { 
     423           
     424              // first we translate into "DivPixel" 
     425              var gPoint = this.fromLatLngToDivPixel(gLatLng); 
     426           
     427              // locate the sliding "Div" div 
     428              //  it seems like "b" is the main div 
     429              var div = this.b.firstChild.firstChild; 
     430           
     431              // adjust by the offset of "Div" and voila! 
     432              gPoint.x += div.offsetLeft; 
     433              gPoint.y += div.offsetTop; 
     434           
     435              return gPoint; 
     436          }; 
     437      } 
     438    }, 
    436439    /** @final @type String */ 
    437440    CLASS_NAME: "OpenLayers.Layer.Google"