Google Maps Find Altitude
Last Updated 29th December 2008
Quick Find :
Description
A method of determining altitude (height) when a point is clicked on a map.
How To Use
- Click on the map on a location where you wish to find the altitude
- The altitude will be displayed in the message box below the map
How it Works
var map;
function Gload()
{
mapDiv.innerHTML='Loading ...';
if(!GBrowserIsCompatible())
{
mapDiv.innerHTML='Sorry, your browser is not compatible with Google Maps.';
return;
}
map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(0,0), 2);
map.setMapType(G_HYBRID_MAP);
GEvent.addListener(map, "click", function(overlay,point,overlaylatlng)
{
if(point)
{
mapDiv.innerHTML="Finding Altitude...";
map.addOverlay(createMarker(point));
findalt(point);
}
});
mapDiv.innerHTML="Ready";
}
function findalt(point)
{
var script = document.createElement("script");
document.body.appendChild(script);
var selectedWebService="gtopo30";
script.src = "http://ws.geonames.org/" + selectedWebService + "JSON?lat=" + point.lat() + "&lng=" + point.lng() + "&callback=loadJSON";
}
function loadJSON(result)
{
var filter = new Array();
filter[0] = "gtopo30";
var output=JSON.stringify(result,filter);
var output2=JSON.parse(output);
mapDiv.innerHTML =output2.gtopo30+"m";
}
function createMarker(point)
{
var marker=new GMarker(point);
return marker;
}
function ClearMap()
{
map.clearOverlays();
mapDiv.innerHTML="";
}
Relevant Links
Further Uses and Ideas
- None at the current time
Version History
- Version 1 (28/09/2008)
- Version 1.1 (28/12/2008) - You are here
- Added quick find option
Previous Comments For This Page
Doesn't seem to work - gives me the same altitude at the top of a nearby hill as at the bottom!
By Neil on 06/01/2009
Doesn't seem to work - gives me the same altitude at the top of a nearby hill as at the bottom!
By Neil on 06/01/2009
Hi, Try the new quick find option to see if it works any better.
By Daft Logic on 29/12/2008
It is too slow. It would be better if I can enter my address. I'm baking a cake and I need to know the altitude for the Oakland hills, CA.
On 29/12/2008
TY.. this works :D
On 17/12/2008
Look right above the "clear map" button. Shows up for me
By Gladys on 28/11/2008
same comment as mary - it does not appear below as suggested
On 26/11/2008
I found my location, but could not get an altitude result.
By Mary on 10/11/2008
Add your own comment below and let others know what you think: