Converting Earth range/altitude to Maps zoom

791 views
Skip to first unread message

fraser (Earth API Guru)

unread,
Aug 27, 2009, 6:38:18 AM8/27/09
to KML Developer Support - Google Earth Plug-in
Hi,

I have been playing around with small earth/map integration page this
morning.

One thing I have been having an issue with is calculating a zoom level
for a static Maps url from a given LookAt range.
What I wish to know is, from a given a view in Google Earth what is
the most accurate way to convert the current 'range' to the equivalent
'zoom' amount?

Anyhow, I have been having limited success with the following...
---------------------------------------------------------------------------------
// get the data required
var lookAt = ge.getView().copyAsLookAt
(ge.ALTITUDE_RELATIVE_TO_GROUND);
var zoom = Math.round(26 - (Math.log(lookAt.getRange()) / Math.log
(2)));

// if(zoom < 0) { zoom = 0; }
// if(zoom > 21) zoom = 21; }

// build the maps url
var url = "http://maps.google.co.uk/?ll=" +
lookAt.getLatitude() + "," + lookAt.getLongitude() +
"&z=" + zoom;
---------------------------------------------------------------------------------

Alternately, I was thinking maybe there was a way to calculate the
'sspn' (screen span) parameter from the plug-in's
getViewportGlobeBounds() method. Anyone have have any thoughts on
this? I'm sure I can work it out given time but I wondered if anyone
had anything already?

...maybe I just need more coffee :)

Thanks,

Fraser.
Message has been deleted

fraser (Earth API Guru)

unread,
Aug 27, 2009, 11:21:18 AM8/27/09
to KML Developer Support - Google Earth Plug-in
Ok I got it working, for anyone that is interested I made a quick demo
page here:
http://www.msa.mmu.ac.uk/~fraser/ge/viewinmaps/

F.

Roman N

unread,
Aug 28, 2009, 3:19:25 PM8/28/09
to KML Developer Support - Google Earth Plug-in
Hey Fraser,

Thanks for posting this--quite useful!

Roman

Avi Revivo

unread,
Jan 9, 2014, 3:46:53 AM1/9/14
to google-earth-...@googlegroups.com
Hi Fraser,

Your link is not working anymore. I got a "Page not found" error...
Do you have another link for your example?
I will be very useful for me.

Thanks,
Avi
Reply all
Reply to author
Forward
0 new messages