OpenLayers OpenLayers

Changeset 1697

Show
Ignore:
Timestamp:
10/13/06 17:29:09 (2 years ago)
Author:
crschmidt
Message:

Vector sandbox commit. This brings us back up to date with where we were last night.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/crschmidt/vector/examples/baseLayers.html

    r1695 r1697  
    1414    <!-- Localhost key --> 
    1515    <!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'></script>--> 
    16     <script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script> 
    1716    <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> 
    18     <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script> 
    1917    <script src="../lib/OpenLayers.js"></script> 
    2018    <script type="text/javascript"> 
     
    3735            var google = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP }); 
    3836            var ve = new OpenLayers.Layer.VirtualEarth( "VE");  
    39             var yahoo = new OpenLayers.Layer.Yahoo( "Yahoo");  
    40             var mm = new OpenLayers.Layer.MultiMap( "MultiMap");  
    4137             
    4238 
    43             map.addLayers([wms, google, ve, yahoo, mm]); 
     39            map.addLayers([wms, google, ve]); 
    4440 
    4541            markers = new OpenLayers.Layer.Markers("markers"); 
     
    4844            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 
    4945            map.addControl( new OpenLayers.Control.LayerSwitcher() ); 
    50             map.addControl( new OpenLayers.Control.MousePosition() ); 
    5146 
    5247        } 
  • sandbox/crschmidt/vector/lib/OpenLayers.js

    r1695 r1697  
    7878        "OpenLayers/Layer/Markers.js", 
    7979        "OpenLayers/Layer/Text.js", 
     80        "OpenLayers/Layer/Vector.js", 
    8081        "OpenLayers/Layer/WorldWind.js", 
    8182        "OpenLayers/Layer/WMS.js", 
     
    9899        "OpenLayers/Control/Permalink.js", 
    99100        "OpenLayers/Control/Scale.js", 
    100         "OpenLayers/Control/LayerSwitcher.js" 
     101        "OpenLayers/Control/LayerSwitcher.js", 
     102        "OpenLayers/Vector.js", 
     103        "OpenLayers/Vector/CanvasStyle.js", 
     104        "OpenLayers/Vector/Point.js", 
     105        "OpenLayers/Vector/Line.js", 
     106        "OpenLayers/Vector/MultiLine.js", 
     107        "OpenLayers/Vector/Polygon.js" 
    101108    ); // etc. 
    102109 
  • sandbox/crschmidt/vector/lib/OpenLayers/Layer/EventPane.js

    r1695 r1697  
    2626    pane: null, 
    2727 
    28  
    29     /** This is the object which will be used to load the 3rd party library 
    30      *   in the case of the google layer, this will be of type GMap,  
    31      *   in the case of the ve layer, this will be of type VEMap 
    32      *  
    33      * @type Object */ 
    34     mapObject: null, 
    35  
    36  
    3728    /** 
    3829     * @constructor 
     
    4435        OpenLayers.Layer.prototype.initialize.apply(this, arguments); 
    4536        if (this.pane == null) { 
    46             this.pane = OpenLayers.Util.createDiv(this.div.id + "_EventPane"); 
     37            this.pane = OpenLayers.Util.createDiv(); 
    4738        } 
    4839    }, 
    49      
    50     /** 
    51      *  
    52      */ 
    53     destroy: function() { 
    54         this.mapObject = null; 
    55         OpenLayers.Layer.prototype.destroy.apply(this, arguments);  
    56     }, 
    57  
    5840     
    5941    /** Set the map property for the layer. This is done through an accessor 
     
    7961            this.map.layerContainerDiv.appendChild(this.pane); 
    8062        } 
    81  
    82         // once our layer has been added to the map, we can load it 
    83         this.loadMapObject(); 
    84      
    85         // if map didn't load, display warning 
    86         if (this.mapObject == null) { 
    87             this.loadWarningMessage(); 
    88         } 
    8963    }, 
    90    
    91     /** If we can't load the GMap, then display an error message to the  
    92      *   user and tell them where to go for help. 
    93      *  
    94      * @private 
    95      *  
    96      */ 
    97     loadWarningMessage:function() { 
    98  
    99         this.div.style.backgroundColor = "darkblue"; 
    100  
    101         var viewSize = this.map.getSize(); 
    102          
    103         msgW = Math.min(viewSize.w, 300); 
    104         msgH = Math.min(viewSize.h, 200); 
    105         var size = new OpenLayers.Size(msgW, msgH); 
    106  
    107         var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2); 
    108  
    109         var topLeft = centerPx.add(-size.w/2, -size.h/2);             
    110  
    111         var div = OpenLayers.Util.createDiv(this.name + "_warning",  
    112                                             topLeft,  
    113                                             size, 
    114                                             null, 
    115                                             null, 
    116                                             null, 
    117                                             "auto"); 
    118  
    119         div.style.padding = "7px"; 
    120         div.style.backgroundColor = "yellow"; 
    121  
    122         div.innerHTML = this.getWarningHTML(); 
    123         this.div.appendChild(div); 
    124     }, 
    125    
    12664   
    12765    /**  
     
    13371    }, 
    13472   
    135     /** 
    136      * @param {int} zIndex 
    137      */ 
    138     setZIndex: function (zIndex) { 
     73    setZIndex: function (zIdx) { 
    13974        OpenLayers.Layer.prototype.setZIndex.apply(this, arguments); 
    14075        this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1; 
    141     }, 
    142  
    143     /**  
    144      * @param {OpenLayers.Bounds} bounds 
    145      * @param {Boolean} zoomChanged 
    146      * @param {Boolean} dragging 
    147      */ 
    148     moveTo:function(bounds, zoomChanged, dragging) { 
    149         OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 
    150  
    151         if (this.mapObject != null) { 
    152  
    153             var newCenter = this.map.getCenter(); 
    154             var newZoom = this.map.getZoom(); 
    155  
    156             if (newCenter != null) { 
    157  
    158                 var moOldCenter = this.getMapObjectCenter(); 
    159                 var oldCenter = this.getOLLonLatFromMapObjectLonLat(moOldCenter); 
    160  
    161                 var moOldZoom = this.getMapObjectZoom(); 
    162                 var oldZoom= this.getOLZoomFromMapObjectZoom(moOldZoom); 
    163  
    164                 if ( !(newCenter.equals(oldCenter)) ||  
    165                      !(newZoom == oldZoom) ) { 
    166  
    167                     var center = this.getMapObjectLonLatFromOLLonLat(newCenter); 
    168                     var zoom = this.getMapObjectZoomFromOLZoom(newZoom); 
    169                     this.setMapObjectCenter(center, zoom); 
    170                 } 
    171             } 
    172         } 
    173     }, 
    174  
    175  
    176   /********************************************************/ 
    177   /*                                                      */ 
    178   /*                 Baselayer Functions                  */ 
    179   /*                                                      */ 
    180   /********************************************************/ 
    181  
    182     /** 
    183      * @param {OpenLayers.Pixel} viewPortPx 
    184      * 
    185      * @returns An OpenLayers.LonLat which is the passed-in view port 
    186      *          OpenLayers.Pixel, translated into lon/lat by GMAPS 
    187      *          If gmap is not loaded or not centered, returns null 
    188      * @type OpenLayers.LonLat 
    189      */ 
    190     getLonLatFromViewPortPx: function (viewPortPx) { 
    191         var lonlat = null; 
    192         if ( (this.mapObject != null) &&  
    193              (this.getMapObjectCenter() != null) ) { 
    194             var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx); 
    195             var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel) 
    196             lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat); 
    197         } 
    198         return lonlat; 
    199     }, 
    200  
    201   
    202     /** 
    203      * @param {OpenLayers.LonLat} lonlat 
    204      * 
    205      * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,  
    206      *          translated into view port pixels BY GMAPS 
    207      *          If gmap is not loaded or not centered, returns null 
    208      * @type OpenLayers.Pixel 
    209      */ 
    210     getViewPortPxFromLonLat: function (lonlat) { 
    211         var viewPortPx = null; 
    212         if ( (this.mapObject != null) &&  
    213              (this.getMapObjectCenter() != null) ) { 
    214  
    215             var moLonLat = this.getMapObjectLonLatFromOLLonLat(lonlat); 
    216             var moPixel = this.getMapObjectPixelFromMapObjectLonLat(moLonLat) 
    217          
    218             viewPortPx = this.getOLPixelFromMapObjectPixel(moPixel); 
    219         } 
    220         return viewPortPx; 
    221     }, 
    222  
    223   /********************************************************/ 
    224   /*                                                      */ 
    225   /*               Translation Functions                  */ 
    226   /*                                                      */ 
    227   /*   The following functions translate Map Object and   */ 
    228   /*            OL formats for Pixel, LonLat              */ 
    229   /*                                                      */ 
    230   /********************************************************/ 
    231  
    232   // 
    233   // TRANSLATION: MapObject LatLng <-> OpenLayers.LonLat 
    234   // 
    235  
    236     /** 
    237      * @param {Object} moLonLat 
    238      *  
    239      * @returns An OpenLayers.LonLat, translated from the passed in  
    240      *          MapObject LonLat 
    241      *          Returns null if null value is passed in 
    242      * @type OpenLayers.LonLat 
    243      */ 
    244     getOLLonLatFromMapObjectLonLat: function(moLonLat) { 
    245         var olLonLat = null; 
    246         if (moLonLat != null) { 
    247             var lon = this.getLongitudeFromMapObjectLonLat(moLonLat); 
    248             var lat = this.getLatitudeFromMapObjectLonLat(moLonLat); 
    249             olLonLat = new OpenLayers.LonLat(lon, lat); 
    250         } 
    251         return olLonLat; 
    252     }, 
    253  
    254     /** 
    255      * @param {OpenLayers.LonLat} olLonLat 
    256      *  
    257      * @returns A MapObject LonLat, translated from the passed in  
    258      *          OpenLayers.LonLat 
    259      *          Returns null if null value is passed in 
    260      * @type Object 
    261      */ 
    262     getMapObjectLonLatFromOLLonLat: function(olLonLat) { 
    263         var moLatLng = null; 
    264         if (olLonLat != null) { 
    265             moLatLng = this.getMapObjectLonLatFromLonLat(olLonLat.lon, 
    266                                                          olLonLat.lat); 
    267         } 
    268         return moLatLng; 
    269     }, 
    270  
    271  
    272   // 
    273   // TRANSLATION: MapObject Pixel <-> OpenLayers.Pixel 
    274   // 
    275  
    276     /** 
    277      * @param {Object} moPixel 
    278      *  
    279      * @returns An OpenLayers.Pixel, translated from the passed in  
    280      *          MapObject Pixel 
    281      *          Returns null if null value is passed in 
    282      * @type OpenLayers.Pixel 
    283      */ 
    284     getOLPixelFromMapObjectPixel: function(moPixel) { 
    285         var olPixel = null; 
    286         if (moPixel != null) { 
    287             var x = this.getXFromMapObjectPixel(moPixel); 
    288             var y = this.getYFromMapObjectPixel(moPixel); 
    289             olPixel = new OpenLayers.Pixel(x, y); 
    290         } 
    291         return olPixel; 
    292     }, 
    293  
    294     /** 
    295      * @param {OpenLayers.Pixel} olPixel 
    296      *  
    297      * @returns A MapObject Pixel, translated from the passed in  
    298      *          OpenLayers.Pixel 
    299      *          Returns null if null value is passed in 
    300      * @type Object 
    301      */ 
    302     getMapObjectPixelFromOLPixel: function(olPixel) { 
    303         var moPixel = null; 
    304         if (olPixel != null) { 
    305             moPixel = this.getMapObjectPixelFromXY(olPixel.x, olPixel.y); 
    306         } 
    307         return moPixel; 
    30876    }, 
    30977 
  • sandbox/crschmidt/vector/lib/OpenLayers/Layer/FixedZoomLevels.js

    r1695 r1697  
    8181                                     : this.map[property]; 
    8282        } 
    83  
     83         
     84         
    8485        if ( (this.minZoomLevel == null) || 
    8586             (this.minZoomLevel < this.MIN_ZOOM_LEVEL) ){ 
    8687            this.minZoomLevel = this.MIN_ZOOM_LEVEL; 
    8788        }         
    88  
     89         
     90         
    8991        var limitZoomLevels = this.MAX_ZOOM_LEVEL - this.minZoomLevel + 1; 
    9092        if (this.numZoomLevels != null) { 
     
    101103        this.maxZoomLevel = this.minZoomLevel + this.numZoomLevels - 1; 
    102104 
    103         if (this.RESOLUTIONS != null) { 
    104             var resolutionsIndex = 0; 
    105             this.resolutions = []; 
    106             for(var i= this.minZoomLevel; i < this.numZoomLevels; i++) { 
    107                 this.resolutions[resolutionsIndex++] = this.RESOLUTIONS[i];             
    108             } 
    109         }         
    110105    }, 
    111106     
     
    115110     */ 
    116111    getResolution: function() { 
    117  
    118         if (this.resolutions != null) { 
    119             return OpenLayers.Layer.prototype.getResolution.apply(this, arguments); 
    120         } else { 
    121             var resolution = null; 
    122              
    123             var viewSize = this.map.getSize(); 
    124             var extent = this.getExtent(); 
    125              
    126             if ((viewSize != null) && (extent != null)) { 
    127                 resolution = Math.max( extent.getWidth()  / viewSize.w, 
    128                                        extent.getHeight() / viewSize.h ); 
    129             } 
    130             return resolution; 
     112        var resolution = null; 
     113         
     114        var viewSize = this.map.getSize(); 
     115        var extent = this.getExtent(); 
     116         
     117        if ((viewSize != null) && (extent != null)) { 
     118            resolution = Math.max( extent.getWidth()  / viewSize.w, 
     119                                   extent.getHeight() / viewSize.h ); 
    131120        } 
     121        return resolution; 
    132122     }, 
    133123 
     
    170160    getZoomForResolution: function(resolution) { 
    171161       
    172         if (this.resolutions != null) { 
    173             return OpenLayers.Layer.prototype.getZoomForResolution.apply(this, arguments); 
    174         } else { 
    175             var extent = OpenLayers.Layer.prototype.getExtent.apply(this,  
    176                                                                     [resolution]); 
    177                                                                      
    178             return this.getZoomForExtent(extent); 
    179         } 
     162        var extent = OpenLayers.Layer.prototype.getExtent.apply(this,  
     163                                                                [resolution]); 
     164                                                                 
     165        return this.getZoomForExtent(extent); 
    180166    }, 
    181  
    182  
    183  
    184      
    185   /********************************************************/ 
    186   /*                                                      */ 
    187   /*             Translation Functions                    */ 
    188   /*                                                      */ 
    189   /*    The following functions translate GMaps and OL    */  
    190   /*     formats for Pixel, LonLat, Bounds, and Zoom      */ 
    191   /*                                                      */ 
    192   /********************************************************/ 
    193  
    194  
    195   // 
    196   // TRANSLATION: MapObject Zoom <-> OpenLayers Zoom 
    197   // 
    198    
    199     /** 
    200      * @param {int} gZoom 
    201      *  
    202      * @returns An OpenLayers Zoom level, translated from the passed in gZoom 
    203      *          Returns null if null value is passed in 
    204      * @type int 
    205      */ 
    206     getOLZoomFromMapObjectZoom: function(moZoom) { 
    207         var zoom = null; 
    208         if (moZoom != null) { 
    209             zoom = moZoom - this.minZoomLevel; 
    210         } 
    211         return zoom; 
    212     }, 
    213      
    214     /** 
    215      * @param {int} olZoom 
    216      *  
    217      * @returns A MapObject level, translated from the passed in olZoom 
    218      *          Returns null if null value is passed in 
    219      * @type int 
    220      */ 
    221     getMapObjectZoomFromOLZoom: function(olZoom) { 
    222         var zoom = null;  
    223         if (olZoom != null) { 
    224             zoom = olZoom + this.minZoomLevel; 
    225         } 
    226         return zoom; 
    227     }, 
    228  
    229167 
    230168    /** @final @type String */ 
  • sandbox/crschmidt/vector/lib/OpenLayers/Layer/Google.js

    r1695 r1697  
    77 *  
    88 * @requires OpenLayers/Layer/EventPane.js 
    9  * @requires OpenLayers/Layer/FixedZoomLevels.js 
    109 */ 
    1110OpenLayers.Layer.Google = OpenLayers.Class.create(); 
     
    2019    MAX_ZOOM_LEVEL: 17, 
    2120 
    22     /** Hardcode these resolutions so that they are more closely 
    23      *   tied with the standard wms projection 
    24      *  
    25      * @final @type Array(float) */ 
    26     RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125], 
     21    /** @type GMap2 gmap stores the Google Map element */ 
     22    gmap:null, 
    2723 
    2824    /** @type GMapType */ 
     
    4137    }, 
    4238     
     39    /** 
     40     *  
     41     */ 
     42    destroy: function() { 
     43        this.gmap = null; 
     44        OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);  
     45    }, 
     46 
     47     /**  
     48     * @param {OpenLayers.Map} map 
     49     */ 
     50    setMap:function(map) { 
     51        OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments); 
     52 
     53        // once our layer has been added to the map, we can load it 
     54        this.loadGMap(); 
     55    }, 
     56     
     57    /** Assuming we are not dragging (in which case GMaps is moving itself,  
     58     *   and the dragging flag is set) we need to move the gmap to the  
     59     *   new center/zoom 
     60     *  
     61     * @param {OpenLayers.Bounds} bounds 
     62     * @param {Boolean} zoomChanged 
     63     * @param {Boolean} dragging 
     64     */ 
     65    moveTo:function(bounds, zoomChanged, dragging) { 
     66        OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments); 
     67 
     68        if ((this.gmap != null) && (!this.dragging)) { 
     69 
     70            var newOLCenter = this.map.getCenter(); 
     71            var newOLZoom = this.map.getZoom(); 
     72 
     73            if (newOLCenter != null) { 
     74 
     75                var oldGCenter = this.gmap.getCenter(); 
     76                var oldOLCenter = this.getOLLonLatFromGLatLng(oldGCenter); 
     77 
     78                var oldGZoom = this.gmap.getZoom(); 
     79                var oldOLZoom = this.getOLZoomFromGZoom(oldGZoom); 
     80                 
     81                if ( !(newOLCenter.equals(oldOLCenter)) ||  
     82                     !(newOLZoom == oldOLZoom) ) { 
     83     
     84                    var newGCenter = this.getGLatLngFromOLLonLat(newOLCenter); 
     85                    var newGZoom = this.getGZoomFromOLZoom(newOLZoom); 
     86 
     87                    this.gmap.setCenter(newGCenter, newGZoom);  
     88                                             
     89                    if (this.type != null) { 
     90                        this.gmap.setMapType(this.type); 
     91                        this.type = null; 
     92                    } 
     93                } 
     94            } 
     95        } 
     96    }, 
     97 
    4398    /** Load the GMap and register appropriate event listeners. If we can't  
    4499     *   load GMap2, then display a warning message. 
    45100     *  
    46101     * @private 
    47      */ 
    48     loadMapObject:function() { 
     102     *  
     103     */ 
     104    loadGMap:function() { 
    49105         
    50106        //has gmaps library has been loaded? 
    51107        try { 
    52108            // create GMap, hide nav controls 
    53             this.mapObject = new GMap2( this.div ); 
     109            this.gmap = new GMap2( this.div ); 
     110            this.gmap.disableDragging(); 
    54111 
    55112            // move the ToS and branding stuff up to the pane 
     
    69126            termsOfUse.style.bottom = ""; 
    70127 
     128            // this causes the GMap to set itself to Map's center/zoom 
     129            this.moveTo(); 
     130 
    71131        } catch (e) { 
    72             // do not crash 
     132            this.loadWarningMessage(); 
    73133        } 
    74134                
    75135    }, 
    76136 
    77     /** Overridden from EventPane because if a map type has been specified,  
    78      *   we need to attach a listener for the first moveend -- this is how  
    79      *   we will know that the map has been centered. Only once the map has  
    80      *   been centered is it safe to change the gmap object's map type.  
    81      *  
    82      * @param {OpenLayers.Map} map 
    83      */ 
    84     setMap: function(map) { 
    85         OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments); 
    86  
    87         if (this.type != null) { 
    88             this.map.events.register("moveend", this, this.setMapType); 
    89         } 
    90     }, 
    91      
    92     /** The map has been centered, and a map type was specified, so we  
    93      *   set the map type on the gmap object, then unregister the listener 
    94      *   so that we dont keep doing this every time the map moves. 
     137    /** 
     138     * @param {Event} evt 
     139     */ 
     140    onMapResize: function() { 
     141        this.gmap.checkResize();   
     142    }, 
     143 
     144    /** If we can't load the GMap, then display an error message to the  
     145     *   user and tell them where to go for help. 
    95146     *  
    96147     * @private 
    97      */ 
    98     setMapType: function() { 
    99         if (this.mapObject.getCenter() != null) { 
    100             this.mapObject.setMapType(this.type); 
    101             this.map.events.unregister("moveend", this, this.setMapType); 
    102         } 
    103     }, 
    104  
    105     /** 
    106      * @param {Event} evt 
    107      */ 
    108     onMapResize: function() { 
    109         this.mapObject.checkResize();   
    110     }, 
    111  
    112  
    113     /** 
    114      * @param {OpenLayers.Bounds} bounds 
    115      * 
    116      * @returns Corresponding zoom level for a specified Bounds.  
    117      *          If mapObject is not loaded or not centered, returns null 
    118      * @type int 
    119      * 
    120     getZoomForExtent: function (bounds) { 
    121         var zoom = null; 
    122         if (this.mapObject != null) { 
    123             var moBounds = this.getMapObjectBoundsFromOLBounds(bounds); 
    124             var moZoom = this.getMapObjectZoomFromMapObjectBounds(moBounds); 
    125  
    126             //make sure zoom is within bounds     
    127             var moZoom = Math.min(Math.max(moZoom, this.minZoomLevel),  
    128                                  this.maxZoomLevel); 
    129  
    130             zoom = this.getOLZoomFromMapObjectZoom(moZoom); 
    131         } 
    132         return zoom; 
    133     }, 
    134      
    135     */ 
    136      
    137   // 
    138   // TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds 
    139   // 
    140  
    141     /** 
    142      * @param {Object} moBounds 
    143      *  
    144      * @returns An OpenLayers.Bounds, translated from the passed-in 
    145      *          MapObject Bounds 
    146      *          Returns null if null value is passed in 
    147      * @type OpenLayers.Bounds 
    148      */ 
    149     getOLBoundsFromMapObjectBounds: function(moBounds) { 
    150         var olBounds = null; 
    151         if (moBounds != null) { 
    152             var sw = moBounds.getSouthWest(); 
    153             var ne = moBounds.getNorthEast(); 
    154             olBounds = new OpenLayers.Bounds(sw.lng(),  
    155                                              sw.lat(),  
    156                                              ne.lng(),  
    157                                              ne.lat() ); 
    158         } 
    159         return olBounds; 
    160     }, 
    161  
    162     /** 
    163      * @param {OpenLayers.Bounds} olBounds 
    164      *  
    165      * @returns A MapObject Bounds, translated from olBounds 
    166      *          Returns null if null value is passed in 
    167      * @type Object 
    168      */ 
    169     getMapObjectBoundsFromOLBounds: function(olBounds) { 
    170         var moBounds = null; 
    171         if (olBounds != null) { 
    172             var sw = new GLatLng(olBounds.bottom, olBounds.left); 
    173             var ne = new GLatLng(olBounds.top, olBounds.right); 
    174             moBounds = new GLatLngBounds(sw, ne); 
    175         } 
    176         return moBounds; 
    177     }, 
    178      
    179  
    180  
    181  
    182  
    183     /** Hack-on function because GMAPS does not give it to us 
    184      *  
    185      * @param {GLatLng} gLatLng  
    186      * 
    187      * @returns A GPoint specifying gLatLng translated into "Container" coords 
    188      * @type GPoint 
    189      */ 
    190     addContainerPxFunction: function() { 
    191         if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) { 
    192            
    193             GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) { 
    194            
    195                 // first we translate into "DivPixel" 
    196                     var gPoint = this.fromLatLngToDivPixel(gLatLng); 
    197        
    198                     // locate the sliding "Div" div 
    199                 //  it seems like "b" is the main div 
    200                     var div = this.b.firstChild.firstChild; 
    201        
    202                     // adjust by the offset of "Div" and voila! 
    203                 gPoint.x += div.offsetLeft; 
    204                 gPoint.y += div.offsetTop; 
    205      
    206                 return gPoint; 
    207             }; 
    208         } 
    209     }, 
    210  
    211     /**  
    212      * @return String with information on why layer is broken, how to get 
    213      *          it working. 
    214      * @type String 
    215      */ 
    216     getWarningHTML:function() { 
     148     *  
     149     */ 
     150    loadWarningMessage:function() { 
     151 
     152        this.div.style.backgroundColor = "darkblue"; 
    217153 
    218154        var html = ""; 
    219155        html += "The Google Layer was unable to load correctly.<br>"; 
    220156        html += "<br>"; 
    221         html += "To get rid of this message, select a new BaseLayer
    222         html += "in the layer switcher in the upper-right corner.<br>"; 
     157        html += "To get rid of this message, click on the Google Layer's
     158        html += "tab in the layer switcher in the upper-right corner.<br>"; 
    223159        html += "<br>"; 
    224160        html += "Most likely, this is because the Google Maps library"; 
     
    232168        html += "</a>"; 
    233169         
    234         return html; 
    235     }, 
    236  
    237  
    238     /************************************ 
    239      *                                  * 
    240      *   MapObject Interface Controls   * 
    241      *                                  * 
    242      ************************************/ 
    243  
    244  
    245   // Get&Set Center, Zoom 
    246  
    247     /** Set the mapObject to the specified center and zoom 
    248      *  
    249      * @param {Object} center MapObject LonLat format 
    250      * @param {int} zoom MapObject zoom format 
    251      */ 
    252     setMapObjectCenter: function(center, zoom) { 
    253         this.mapObject.setCenter(center, zoom);  
    254     }, 
    255     
    256     /** 
    257      * @returns the mapObject's current center in Map Object format 
    258      * @type Object 
    259      */ 
    260     getMapObjectCenter: function() { 
    261         return this.mapObject.getCenter(); 
    262     }, 
    263  
    264     /**  
    265      * @returns the mapObject's current zoom, in Map Object format 
     170        var viewSize = this.map.getSize(); 
     171         
     172        msgW = Math.min(viewSize.w, 300); 
     173        msgH = Math.min(viewSize.h, 200); 
     174        var size = new OpenLayers.Size(msgW, msgH); 
     175 
     176        var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2); 
     177 
     178        var topLeft = centerPx.add(-size.w/2, -size.h/2);             
     179 
     180        var div = OpenLayers.Util.createDiv("gmapsWarning",  
     181                                            topLeft,  
     182                                            size, 
     183                                            null, 
     184                                            null, 
     185                                            null, 
     186                                            "auto"); 
     187 
     188        div.style.padding = "7px"; 
     189        div.style.backgroundColor = "yellow"; 
     190 
     191        div.innerHTML = html; 
     192        this.div.appendChild(div); 
     193    }, 
     194 
     195 
     196 
     197  /********************************************************/ 
     198  /*                                                      */ 
     199  /*                 Baselayer Functions                  */ 
     200  /*                                                      */ 
     201  /********************************************************/ 
     202 
     203    /** 
     204     * @param {OpenLayers.Pixel} viewPortPx 
     205     * 
     206     * @returns An OpenLayers.LonLat which is the passed-in view port 
     207     *          OpenLayers.Pixel, translated into lon/lat by GMAPS 
     208     *          If gmap is not loaded or not centered, returns null 
     209     * @type OpenLayers.LonLat 
     210     */ 
     211    getLonLatFromViewPortPx: function (viewPortPx) { 
     212        var lonlat = null; 
     213        if ((this.gmap != null) && (this.gmap.getCenter() != null)) { 
     214            var gPoint = this.getGPointFromOLPixel(viewPortPx); 
     215            var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint) 
     216            lonlat = this.getOLLonLatFromGLatLng(gLatLng); 
     217        } 
     218        return lonlat; 
     219    }, 
     220 
     221  
     222    /** 
     223     * @param {OpenLayers.LonLat} lonlat 
     224     * 
     225     * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,  
     226     *          translated into view port pixels BY GMAPS 
     227     *          If gmap is not loaded or not centered, returns null 
     228     * @type OpenLayers.Pixel 
     229     */ 
     230    getViewPortPxFromLonLat: function (lonlat) { 
     231        var viewPortPx = null; 
     232        if ((this.gmap != null) && (this.gmap.getCenter() != null)) { 
     233            var gLatLng = this.getGLatLngFromOLLonLat(lonlat); 
     234         
     235            // note we use special hacked function here 
     236            var gPoint = this.gmap.fromLatLngToContainerPixel(gLatLng); 
     237         
     238            viewPortPx = this.getOLPixelFromGPoint(gPoint); 
     239        } 
     240        return viewPortPx; 
     241    }, 
     242 
     243 
     244    /** 
     245     * @param {OpenLayers.Bounds} bounds 
     246     * 
     247     * @returns Corresponding zoom level for a specified Bounds.  
     248     *          If gmap is not loaded or not centered, returns null 
    266249     * @type int 
    267250     */ 
    268     getMapObjectZoom: function() { 
    269         return this.mapObject.getZoom(); 
    270     }, 
    271  
    272  
    273   // LonLat - Pixel Translation 
     251    getZoomForExtent: function (bounds) { 
     252        var zoom = null; 
     253        if ((this.gmap != null) && (this.gmap.getCenter() != null)) { 
     254            var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); 
     255            var gZoom = this.gmap.getBoundsZoomLevel(gBounds); 
     256 
     257            //make sure zoom is within bounds     
     258            var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),  
     259                                 this.maxZoomLevel); 
     260 
     261            zoom = this.getOLZoomFromGZoom(gZoom); 
     262        } 
     263        return zoom; 
     264    }, 
     265     
     266  /********************************************************/ 
     267  /*                                                      */ 
     268  /*             Translation Functions                    */ 
     269  /*                                                      */ 
     270  /*    The following functions translate GMaps and OL    */  
     271  /*     formats for Pixel, LonLat, Bounds, and Zoom      */ 
     272  /*                                                      */ 
     273  /********************************************************/ 
     274 
     275  // 
     276  // TRANSLATION: GZoom <-> OpenLayers Zoom 
     277  // 
    274278   
    275     /**  
    276      * @param {Object} moPixel MapObject Pixel format 
    277      *  
    278      * @returns MapObject LonLat translated from MapObject Pixel 
    279      * @type Object 
    280      */ 
    281     getMapObjectLonLatFromMapObjectPixel: function(moPixel) { 
    282         return this.mapObject.fromContainerPixelToLatLng(moPixel); 
    283     }, 
    284  
    285     /**  
    286      * @param {Object} moPixel MapObject Pixel format 
    287      *  
    288      * @returns MapObject Pixel translated from MapObject LonLat 
    289      * @type Object 
    290      */ 
    291     getMapObjectPixelFromMapObjectLonLat: function(moLonLat) { 
    292         return this.mapObject.fromLatLngToContainerPixel(moLonLat); 
    293     }, 
    294  
    295    
    296   // Bounds 
    297    
    298     /**  
    299      * @param {Object} moBounds MapObject Bounds format 
    300      *  
    301      * @returns MapObject Zoom for specified MapObject Bounds 
    302      * @type Object 
    303      */ 
    304     getMapObjectZoomFromMapObjectBounds: function(moBounds) { 
    305         return this.mapObject.getBoundsZoomLevel(moBounds); 
    306     }, 
    307  
    308     /************************************ 
    309      *                                  * 
    310      *       MapObject Primitives       * 
    311      *                                  * 
    312      ************************************/ 
    313  
    314  
    315   // LonLat 
    316      
    317     /** 
    318      * @param {Object} moLonLat MapObject LonLat format 
    319      *  
    320      * @returns Longitude of the given MapObject LonLat 
    321      * @type float 
    322      */ 
    323     getLongitudeFromMapObjectLonLat: function(moLonLat) { 
    324         return moLonLat.lng();   
    325     }, 
    326  
    327     /** 
    328      * @param {Object} moLonLat MapObject LonLat format 
    329      *  
    330      * @returns Latitude of the given MapObject LonLat 
    331      * @type float 
    332      */ 
    333     getLatitudeFromMapObjectLonLat: function(moLonLat) { 
    334         return moLonLat.lat();   
    335     }, 
    336      
    337     /** 
    338      * @param {int} lon float 
    339      * @param {int} lat float 
    340      *  
    341      * @returns MapObject LonLat built from lon and lat params 
    342      * @type Object 
    343      */ 
    344     getMapObjectLonLatFromLonLat: function(lon, lat) { 
    345         return new GLatLng(lat, lon); 
    346     }, 
    347  
    348   // Pixel 
    349      
    350     /**  
    351      * @param {Object} moPixel MapObject Pixel format 
    352      *  
    353      * @returns X value of the MapObject Pixel 
     279    /** 
     280     * @param {int} gZoom 
     281     *  
     282     * @returns An OpenLayers Zoom level, translated from the passed in gZoom 
     283     *          Returns null if null value is passed in 
    354284     * @type int 
    355285     */