Index: trunk/extensions/Maps/includes/services/GoogleMaps3/jquery.googlemap.js |
— | — | @@ -228,14 +228,41 @@ |
229 | 229 | mw.loader.using( 'ext.maps.gm3.earth', function() { |
230 | 230 | if ( google.earth.isSupported() ) { |
231 | 231 | var ge = new GoogleEarth( map ); |
| 232 | + var setTilt = function() { |
| 233 | + if ( ge.getInstance() !== undefined ) { |
| 234 | + var center = map.getCenter(); |
| 235 | + var lookAt = ge.instance_.createLookAt(''); |
| 236 | + var range = Math.pow(2, GoogleEarth.MAX_EARTH_ZOOM_ - map.getZoom()); |
| 237 | + lookAt.setRange(range); |
| 238 | + lookAt.setLatitude(center.lat()); |
| 239 | + lookAt.setLongitude(center.lng()); |
| 240 | + lookAt.setHeading(0); |
| 241 | + lookAt.setAltitude(0); |
| 242 | + |
| 243 | + // Teleport to the pre-tilt view immediately. |
| 244 | + ge.instance_.getOptions().setFlyToSpeed(5); |
| 245 | + ge.instance_.getView().setAbstractView(lookAt); |
| 246 | + lookAt.setTilt(options.tilt); |
| 247 | + // Fly to the tilt at regular speed in 200ms |
| 248 | + ge.instance_.getOptions().setFlyToSpeed(0.75); |
| 249 | + window.setTimeout(function() { |
| 250 | + ge.instance_.getView().setAbstractView(lookAt); |
| 251 | + }, 200); |
| 252 | + // Set the flyto speed back to default after the animation starts. |
| 253 | + window.setTimeout(function() { |
| 254 | + ge.instance_.getOptions().setFlyToSpeed(1); |
| 255 | + }, 250); |
| 256 | + } |
| 257 | + else { |
| 258 | + setTimeout( this, 100 ); |
| 259 | + } |
| 260 | + }; |
232 | 261 | |
233 | | - //var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND); |
234 | | - |
235 | | - //lookAt.setTilt(lookAt.getTilt() + options.tilt); |
236 | | - //ge.getView().setAbstractView(lookAt); |
| 262 | + setTilt(); |
237 | 263 | } |
| 264 | + |
238 | 265 | _this.addOverlays(); |
239 | | - map.setMapTypeId(GoogleEarth.MAP_TYPE_ID); |
| 266 | + map.setMapTypeId( GoogleEarth.MAP_TYPE_ID ); |
240 | 267 | } ); |
241 | 268 | } } ); |
242 | 269 | } |