Changeset 910
- Timestamp:
- 07/07/06 08:55:39 (2 years ago)
- Files:
-
- trunk/openlayers/build/library.cfg (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Google.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/build/library.cfg
r773 r910 8 8 9 9 [exclude] 10 OpenLayers/Layer/Google.js11 10 OpenLayers/Layer/Yahoo.js 12 11 OpenLayers/Layer/VirtualEarth.js trunk/openlayers/lib/OpenLayers.js
r886 r910 65 65 "OpenLayers/Tile/Image.js", 66 66 "OpenLayers/Tile/WFS.js", 67 //"OpenLayers/Layer/Google.js",67 "OpenLayers/Layer/Google.js", 68 68 // "OpenLayers/Layer/VirtualEarth.js", 69 69 // "OpenLayers/Layer/Yahoo.js", trunk/openlayers/lib/OpenLayers/Layer/Google.js
r836 r910 3 3 * text of the license. */ 4 4 // @require: OpenLayers/Layer.js 5 6 // load Google map control script7 // this key was generated for: http://openlayers.python-hosting.com/testing/euzuro/8 document.write("<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAmQ3udCHPQVB_9T_edFZ7YRRRlP-tOiFgaSzksg_0w1dphL9c5BTfdJMKT91b0UJGibNcWEM0Q5-O1w'></script>");9 5 10 6 /** … … 59 55 */ 60 56 isBaseLayer: function() { 61 return true;57 return (this.gmap != null); 62 58 }, 63 59 … … 96 92 loadGMap:function() { 97 93 98 // create GMap, hide nav controls 99 this.gmap = new GMap2(this.div); 100 101 // this causes the GMap to set itself to Map's center/zoom 102 this.moveTo(); 103 104 // catch pans and zooms from GMap 105 GEvent.addListener(this.gmap, 106 "moveend", 107 this.catchPanZoom.bindAsEventListener(this)); 108 109 110 // attach to the drag start and end and weŽll set a flag so that 111 // we dont get recursivity. this is because when we call setCenter(), 112 // it calls moveTo() on all layers 113 GEvent.addListener(this.gmap, 114 "dragstart", 115 this.dragStart.bindAsEventListener(this)); 116 117 GEvent.addListener(this.gmap, 118 "dragend", 119 this.dragEnd.bindAsEventListener(this)); 120 121 // catch pans and zooms from GMap 122 GEvent.addListener(this.gmap, 123 "drag", 124 this.catchPanZoom.bindAsEventListener(this)); 125 94 //test if the gmaps library has been loaded 95 var gmapsLoaded = (typeof GMap2) != "undefined"; 96 if (gmapsLoaded) { 97 98 // create GMap, hide nav controls 99 this.gmap = new GMap2(this.div); 100 101 // this causes the GMap to set itself to Map's center/zoom 102 this.moveTo(); 103 104 // catch pans and zooms from GMap 105 GEvent.addListener(this.gmap, 106 "moveend", 107 this.catchPanZoom.bindAsEventListener(this)); 108 109 110 // attach to the drag start and end and weŽll set a flag so that 111 // we dont get recursivity. this is because when we call setCenter(), 112 // it calls moveTo() on all layers 113 GEvent.addListener(this.gmap, 114 "dragstart", 115 this.dragStart.bindAsEventListener(this)); 116 117 GEvent.addListener(this.gmap, 118 "dragend", 119 this.dragEnd.bindAsEventListener(this)); 120 121 // catch pans and zooms from GMap 122 GEvent.addListener(this.gmap, 123 "drag", 124 this.catchPanZoom.bindAsEventListener(this)); 125 } 126 126 }, 127 127 … … 162 162 * @returns An OpenLayers.LonLat which is the passed-in view port 163 163 * OpenLayers.Pixel, translated into lon/lat by GMAPS 164 * If gmap is not loaded, returns null. 164 165 * @type OpenLayers.LonLat 165 166 */ 166 167 getLonLatFromViewPortPx: function (viewPortPx) { 167 var gPoint = this.getGPointFromOLPixel(viewPortPx); 168 var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint) 169 170 return this.getOLLonLatFromGLatLng(gLatLng); 168 var lonlat = null; 169 if (this.gmap != null) { 170 var gPoint = this.getGPointFromOLPixel(viewPortPx); 171 var gLatLng = this.gmap.fromContainerPixelToLatLng(gPoint) 172 lonlat = this.getOLLonLatFromGLatLng(gLatLng); 173 } 174 return lonlat; 171 175 }, 172 176 … … 177 181 * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, 178 182 * translated into view port pixels BY GMAPS 183 * If gmap is not loaded, returns null. 179 184 * @type OpenLayers.Pixel 180 185 */ 181 getViewPortPxFromLonLat: function (lonlat) { 182 var gLatLng = this.getGLatLngFromOLLonLat(lonlat); 183 184 // note we use special hacked function here, 185 // because GMaps doesnt give it to us 186 var gPoint = this.fromLatLngToContainerPixel(gLatLng); 187 188 return this.getOLPixelFromGPoint(gPoint); 186 getViewPortPxFromLonLat: function (lonlat) { 187 var viewPortPx = null; 188 if (this.gmap != null) { 189 var gLatLng = this.getGLatLngFromOLLonLat(lonlat); 190 191 // note we use special hacked function here, 192 // because GMaps doesnt give it to us 193 var gPoint = this.fromLatLngToContainerPixel(gLatLng); 194 195 viewPortPx = this.getOLPixelFromGPoint(gPoint); 196 } 197 return viewPortPx; 189 198 }, 190 199 … … 218 227 * @param {OpenLayers.Bounds} bounds 219 228 * 220 * @return {int} 229 * @returns Corresponding zoom level for a specified Bounds. 230 * If gmap is not loaded, returns null. 231 * @type int 221 232 */ 222 233 getZoomForExtent: function (bounds) { 223 var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); 224 var gZoom = this.gmap.getBoundsZoomLevel(gBounds); 225 226 return this.getOLZoomFromGZoom(gZoom); 234 var zoom = null; 235 if (this.gmap != null) { 236 var gBounds = this.getGLatLngBoundsFromOLBounds(bounds); 237 var gZoom = this.gmap.getBoundsZoomLevel(gBounds); 238 zoom = this.getOLZoomFromGZoom(gZoom); 239 } 240 return zoom; 227 241 }, 228 242 … … 230 244 * @returns A Bounds object which represents the lon/lat bounds of the 231 245 * current viewPort. 246 * If gmap is not loaded, returns null 232 247 * @type OpenLayers.Bounds 233 248 */ 234 249 getExtent: function () { 235 if (this.gmap.getCenter() == null) { 236 this.moveTo(); 237 } 238 var gLatLngBounds = this.gmap.getBounds(); 239 return this.getOLBoundsFromGLatLngBounds(gLatLngBounds); 250 var extent = null; 251 if (this.gmap != null) { 252 if (this.gmap.getCenter() == null) { 253 this.moveTo(); 254 } 255 var gLatLngBounds = this.gmap.getBounds(); 256 extent = this.getOLBoundsFromGLatLngBounds(gLatLngBounds); 257 } 258 return extent; 240 259 }, 241 260
