Changeset 4221
- Timestamp:
- 09/11/07 16:16:28 (11 months ago)
- Files:
-
- trunk/openlayers/examples/google-factbook-tc.html (added)
- trunk/openlayers/examples/google-factbook.html (added)
- trunk/openlayers/examples/multimap-mercator.html (added)
- trunk/openlayers/examples/spherical-mercator.html (added)
- trunk/openlayers/lib/OpenLayers.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Google.js (modified) (10 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/MultiMap.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/SphericalMercator.js (added)
- trunk/openlayers/lib/OpenLayers/Layer/VirtualEarth.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Yahoo.js (modified) (5 diffs)
- trunk/openlayers/tests/Layer/test_Google.html (modified) (1 diff)
- trunk/openlayers/tests/Layer/test_SphericalMercator.html (added)
- trunk/openlayers/tests/list-tests.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers.js
r4205 r4221 89 89 "OpenLayers/Tile/WFS.js", 90 90 "OpenLayers/Layer/Image.js", 91 "OpenLayers/Layer/SphericalMercator.js", 91 92 "OpenLayers/Layer/EventPane.js", 92 93 "OpenLayers/Layer/FixedZoomLevels.js", trunk/openlayers/lib/OpenLayers/Layer/Google.js
r4110 r4221 5 5 6 6 /** 7 * @requires OpenLayers/Layer/SphericalMercator.js 7 8 * @requires OpenLayers/Layer/EventPane.js 8 9 * @requires OpenLayers/Layer/FixedZoomLevels.js … … 11 12 * 12 13 * Inherits: 14 * - <OpenLayers.Layer.SphericalMercator> 13 15 * - <OpenLayers.Layer.EventPane> 14 16 * - <OpenLayers.Layer.FixedZoomLevels> 15 17 */ 16 OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.EventPane, 17 OpenLayers.Layer.FixedZoomLevels, { 18 OpenLayers.Layer.Google = OpenLayers.Class( 19 OpenLayers.Layer.EventPane, 20 OpenLayers.Layer.FixedZoomLevels, { 18 21 19 22 /** … … 63 66 type: null, 64 67 68 /** 69 * APIProperty: sphericalMercator 70 * {Boolean} Should the map act as a mercator-projected map? This will 71 * cause all interactions with the map to be in the actual map projection, 72 * which allows support for vector drawing, overlaying other maps, etc. 73 */ 74 sphericalMercator: false, 75 65 76 /** 66 77 * Constructor: OpenLayers.Layer.Google … … 75 86 arguments); 76 87 this.addContainerPxFunction(); 88 if (this.sphericalMercator) { 89 OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator); 90 this.initMercatorParameters(); 91 } 77 92 }, 78 93 … … 152 167 }, 153 168 154 155 169 /** 156 170 * APIMethod: getZoomForExtent … … 200 214 var sw = moBounds.getSouthWest(); 201 215 var ne = moBounds.getNorthEast(); 202 olBounds = new OpenLayers.Bounds(sw.lng(), 203 sw.lat(), 204 ne.lng(), 205 ne.lat() ); 216 if (this.sphericalMercator) { 217 sw = this.forwardMercator(sw.lng(), sw.lat()); 218 ne = this.forwardMercator(ne.lng(), ne.lat()); 219 } else { 220 sw = new OpenLayers.LonLat(sw.lng(), sw.lat()); 221 ne = new OpenLayers.LonLat(ne.lng(), ne.lat()); 222 } 223 olBounds = new OpenLayers.Bounds(sw.lon, 224 sw.lat, 225 ne.lon, 226 ne.lat ); 206 227 } 207 228 return olBounds; … … 221 242 var moBounds = null; 222 243 if (olBounds != null) { 223 var sw = new GLatLng(olBounds.bottom, olBounds.left); 224 var ne = new GLatLng(olBounds.top, olBounds.right); 225 moBounds = new GLatLngBounds(sw, ne); 244 var sw = this.sphericalMercator ? 245 this.inverseMercator(olBounds.bottom, olBounds.left) : 246 new OpenLayers.LonLat(olBounds.bottom, olBounds.left); 247 var ne = this.sphericalMercator ? 248 this.inverseMercator(olBounds.top, olBounds.right) : 249 new OpenLayers.LonLat(olBounds.top, olBounds.right); 250 moBounds = new GLatLngBounds(new GLatLng(sw.lat, sw.lon), 251 new GLatLng(ne.lat, ne.lon)); 226 252 } 227 253 return moBounds; 228 254 }, 229 230 231 232 233 255 234 256 /** … … 397 419 */ 398 420 getLongitudeFromMapObjectLonLat: function(moLonLat) { 399 return moLonLat.lng(); 421 return this.sphericalMercator ? 422 this.forwardMercator(moLonLat.lng(), moLonLat.lat()).lon : 423 moLonLat.lng(); 400 424 }, 401 425 … … 410 434 */ 411 435 getLatitudeFromMapObjectLonLat: function(moLonLat) { 412 return moLonLat.lat(); 436 var lat = this.sphericalMercator ? 437 this.forwardMercator(moLonLat.lng(), moLonLat.lat()).lat : 438 moLonLat.lat(); 439 return lat; 413 440 }, 414 441 … … 424 451 */ 425 452 getMapObjectLonLatFromLonLat: function(lon, lat) { 426 return new GLatLng(lat, lon); 453 var gLatLng; 454 if(this.sphericalMercator) { 455 var lonlat = this.inverseMercator(lon, lat); 456 gLatLng = new GLatLng(lonlat.lat, lonlat.lon); 457 } else { 458 gLatLng = new GLatLng(lat, lon); 459 } 460 return gLatLng; 427 461 }, 428 462 trunk/openlayers/lib/OpenLayers/Layer/MultiMap.js
r4110 r4221 8 8 * 9 9 * Class: OpenLayers.Layer.MultiMap 10 * Note that MultiMap does not fully support the sphericalMercator 11 * option. See Ticket #953 for more details. 10 12 * 11 13 * Inherits: … … 70 72 OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, 71 73 arguments); 74 if (this.sphericalMercator) { 75 OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator); 76 this.initMercatorParameters(); 77 this.RESOLUTIONS.unshift(10); 78 } 72 79 }, 73 80 … … 202 209 */ 203 210 getLongitudeFromMapObjectLonLat: function(moLonLat) { 204 return moLonLat.lon; 211 return this.sphericalMercator ? 212 this.forwardMercator(moLonLat.lon, moLonLat.lat).lon : 213 moLonLat.lon; 205 214 }, 206 215 … … 215 224 */ 216 225 getLatitudeFromMapObjectLonLat: function(moLonLat) { 217 return moLonLat.lat; 226 return this.sphericalMercator ? 227 this.forwardMercator(moLonLat.lon, moLonLat.lat).lat : 228 moLonLat.lat; 218 229 }, 219 230 … … 229 240 */ 230 241 getMapObjectLonLatFromLonLat: function(lon, lat) { 231 return new MMLatLon(lat, lon); 242 var mmLatLon; 243 if(this.sphericalMercator) { 244 var lonlat = this.inverseMercator(lon, lat); 245 mmLatLon = new MMLatLon(lonlat.lat, lonlat.lon); 246 } else { 247 mmLatLon = new MMLatLon(lat, lon); 248 } 249 return mmLatLon; 232 250 }, 233 251 trunk/openlayers/lib/OpenLayers/Layer/VirtualEarth.js
r4110 r4221 15 15 */ 16 16 OpenLayers.Layer.VirtualEarth = OpenLayers.Class( 17 OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, { 17 OpenLayers.Layer.EventPane, 18 OpenLayers.Layer.FixedZoomLevels, { 18 19 19 20 /** … … 59 60 type: null, 60 61 62 /** 63 * APIProperty: sphericalMercator 64 * {Boolean} Should the map act as a mercator-projected map? This will 65 * cause all interactions with the map to be in the actual map 66 * projection, which allows support for vector drawing, overlaying 67 * other maps, etc. 68 */ 69 sphericalMercator: false, 70 61 71 /** 62 72 * Constructor: OpenLayers.Layer.VirtualEarth … … 70 80 OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, 71 81 arguments); 82 if(this.sphericalMercator) { 83 OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator); 84 this.initMercatorParameters(); 85 } 72 86 }, 73 87 … … 215 229 */ 216 230 getLongitudeFromMapObjectLonLat: function(moLonLat) { 217 return moLonLat.Longitude; 231 return this.sphericalMercator ? 232 this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lon : 233 moLonLat.Longitude; 218 234 }, 219 235 … … 228 244 */ 229 245 getLatitudeFromMapObjectLonLat: function(moLonLat) { 230 return moLonLat.Latitude; 246 return this.sphericalMercator ? 247 this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lat : 248 moLonLat.Latitude; 231 249 }, 232 250 … … 242 260 */ 243 261 getMapObjectLonLatFromLonLat: function(lon, lat) { 244 return new VELatLong(lat, lon); 262 var veLatLong; 263 if(this.sphericalMercator) { 264 var lonlat = this.inverseMercator(lon, lat); 265 veLatLong = new VELatLong(lonlat.lat, lonlat.lon); 266 } else { 267 veLatLong = new VELatLong(lat, lon); 268 } 269 return veLatLong; 245 270 }, 246 271 trunk/openlayers/lib/OpenLayers/Layer/Yahoo.js
r4110 r4221 58 58 */ 59 59 type: null, 60 61 /** 62 * APIProperty: sphericalMercator 63 * {Boolean} Should the map act as a mercator-projected map? This will 64 * cause all interactions with the map to be in the actual map projection, 65 * which allows support for vector drawing, overlaying other maps, etc. 66 */ 67 sphericalMercator: false, 60 68 61 69 /** … … 70 78 OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, 71 79 arguments); 80 if(this.sphericalMercator) { 81 OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator); 82 this.initMercatorParameters(); 83 } 72 84 }, 73 85 … … 295 307 */ 296 308 getLongitudeFromMapObjectLonLat: function(moLonLat) { 297 return moLonLat.Lon; 309 return this.sphericalMercator ? 310 this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lon : 311 moLonLat.Lon; 298 312 }, 299 313 … … 308 322 */ 309 323 getLatitudeFromMapObjectLonLat: function(moLonLat) { 310 return moLonLat.Lat; 324 return this.sphericalMercator ? 325 this.forwardMercator(moLonLat.Lon, moLonLat.Lat).lat : 326 moLonLat.Lat; 311 327 }, 312 328 … … 322 338 */ 323 339 getMapObjectLonLatFromLonLat: function(lon, lat) { 324 return new YGeoPoint(lat, lon); 340 var yLatLong; 341 if(this.sphericalMercator) { 342 var lonlat = this.inverseMercator(lon, lat); 343 yLatLong = new YGeoPoint(lonlat.lat, lonlat.lon); 344 } else { 345 yLatLong = new YGeoPoint(lat, lon); 346 } 347 return yLatLong; 325 348 }, 326 349 trunk/openlayers/tests/Layer/test_Google.html
r4087 r4221 129 129 } 130 130 } 131 132 function test_Layer_Goole_forwardMercator(t){ 133 t.plan(2); 134 //Just test that the fowardMercator function still exists. 135 var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true}); 136 layer.forwardMercator = function(evt) { 137 t.ok( true, "GoogleMercator.forwardMercator was called and executed." ); 138 return; 139 } 140 layer.forwardMercator(); 141 //Now test the fowardMercator returns the expected LonLat object 142 var layer = new OpenLayers.Layer.Google('Test Layer', {'sphericalMercator': true}); 143 var lonlat2 = new OpenLayers.LonLat(Math.random(),Math.random()); 144 var result = layer.forwardMercator(lonlat2.lon, lonlat2.lat); 145 t.ok( result instanceof OpenLayers.LonLat, "OpenLayers.Google.fowardMercator returns LonLat object" ); 146 147 } 131 148 132 149 function test_Layer_Google_overlay(t) { trunk/openlayers/tests/list-tests.html
r4218 r4221 41 41 <li>Layer/test_FixedZoomLevels.html</li> 42 42 <li>Layer/test_GeoRSS.html</li> 43 <li>Layer/test_SphericalMercator.html</li> 43 44 <li>Layer/test_Google.html</li> 44 45 <li>Layer/test_Grid.html</li>
