OpenLayers OpenLayers

Changeset 911

Show
Ignore:
Timestamp:
07/07/06 09:20:33 (2 years ago)
Author:
euzuro
Message:

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.

Files:

Legend:

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

    r910 r911  
    22 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full 
    33 * text of the license. */ 
     4 
    45// @require: OpenLayers/Layer.js 
     6 
     7 
     8if (typeof GMap2 != "undefined") { 
     9     
     10    /** Hack-on function because GMAPS does not give it to us 
     11     *  
     12     * @param {GLatLng} gLatLng  
     13     * 
     14     * @returns A GPoint specifying gLatLng translated into "Container" coords 
     15     * @type GPoint 
     16     */ 
     17    GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) { 
     18     
     19        // first we translate into "DivPixel" 
     20        var gPoint = this.fromLatLngToDivPixel(gLatLng); 
     21     
     22        // locate the sliding "Div" div 
     23        //  it seems like "b" is the main div 
     24        var div = this.b.firstChild.firstChild; 
     25     
     26        // adjust by the offset of "Div" and voila! 
     27        gPoint.x += div.offsetLeft; 
     28        gPoint.y += div.offsetTop; 
     29     
     30        return gPoint; 
     31    }; 
     32} 
    533 
    634/** 
     
    189217            var gLatLng = this.getGLatLngFromOLLonLat(lonlat); 
    190218         
    191             // note we use special hacked function here,  
    192             // because GMaps doesnt give it to us 
    193             var gPoint = this.fromLatLngToContainerPixel(gLatLng); 
     219            // note we use special hacked function here 
     220            var gPoint = this.gmap.fromLatLngToContainerPixel(gLatLng); 
    194221         
    195222            viewPortPx = this.getOLPixelFromGPoint(gPoint); 
    196223        } 
    197224        return viewPortPx; 
    198     }, 
    199  
    200     /** Hacked function because GMAPS does not give us  
    201      *  a fromLatLngToContainerPixel. Cheers sde for the  
    202      *  firstChild.firstChild find. 
    203      *  
    204      * @param {GLatLng} gLatLng  
    205      * 
    206      * @returns A GPoint specifying gLatLng translated into "Container"  
    207      *          coordinates 
    208      * @type GPoint 
    209      */ 
    210     fromLatLngToContainerPixel: function(gLatLng) { 
    211      
    212         // first we translate into "DivPixel" 
    213         var gPoint = this.gmap.fromLatLngToDivPixel(gLatLng); 
    214      
    215         // locate the sliding "Div" div 
    216         var div = this.div.firstChild.firstChild; 
    217      
    218         // adjust by the offset of "Div" and voila! 
    219         gPoint.x += div.offsetLeft; 
    220         gPoint.y += div.offsetTop; 
    221      
    222         return gPoint; 
    223225    }, 
    224226