Logic, but in a different way

Daft Logic

Google Maps Find Altitude

Last Updated 31st August 2011

Search :

[Map Height : Small - Medium - Large]

Output latitude,longitude? Output in meters? Output in feet?

Description

A method of determining altitude (height) when a point is clicked on a map.

How To Use

  1. Click on the map on a location where you wish to find the altitude
  2. The altitude will be displayed in the message box below the map and when you hover over the marker
  3. You can click to place more than one marker and return to hover over each in order to find out the altitude again
  4. Click the [Clear Map] button in order to remove all markers and start again
  5. Use the search option to find a place

You can also access a CSV list of latitude, longitude, altitude in meters and altitude in feet for every marker you place on the map.

How it Works


var outputDiv=document.getElementById('outputDiv');
var map;
var routeMarkers=new Array(0);

function initialize()
{

var latlng = new google.maps.LatLng(0,0);
//setCursor:'crosshair'
var myOptions = {zoom:1,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP,draggableCursor:'crosshair',mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU}};
map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);

// Create ElevationService
elevator = new google.maps.ElevationService();

// Add a listener for the click event and call getElevation on that location
google.maps.event.addListener(map, 'click', getElevation);
}

function getElevation(event)
{
var locations = [];

// Retrieve the clicked location and push it on the array
var clickedLocation = event.latLng;
locations.push(clickedLocation);

// Create a LocationElevationRequest object using the array's one value
var positionalRequest = {'locations': locations};

// Initiate the location request
elevator.getElevationForLocations(positionalRequest, function(results, status)
{
if (status == google.maps.ElevationStatus.OK)
{
// Retrieve the first result
if (results[0])
{
// Open an info window indicating the elevation at the clicked position
outputDiv.innerHTML= "Last point clicked : " + results[0].elevation.toFixed(3) + " m";
var marker=placeMarker(clickedLocation,results[0].elevation.toFixed(3) + " m");
marker.setMap(map);
routeMarkers.push(marker);
}
else
{
outputDiv.innerHTML="No results found";
}
}
else
{
outputDiv.innerHTML="Elevation service failed due to: " + status;
}
});
}

function placeMarker(location,text)
{
var image = new google.maps.MarkerImage('http://www.daftlogic.com/images/gmmarkersv3/stripes.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(20, 34),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(9, 33));
var shadow = new google.maps.MarkerImage('http://www.daftlogic.com/images/gmmarkersv3/shadow.png',
// The shadow image is larger in the horizontal dimension
// while the position and offset are the same as for the main image.
new google.maps.Size(28, 22),
new google.maps.Point(0,0),
new google.maps.Point(1, 22));

var marker = new google.maps.Marker({position:location,map:map,shadow:shadow,icon:image,title:text});

return marker;
}

function clearmap()
{
if (routeMarkers)
{
for (i in routeMarkers)
{
routeMarkers[i].setMap(null);
}
}
routeMarkers=new Array(0);
}

Relevant Links

Google Maps API

Version History

Previous Comments For This Page

Can i enter a lisy of X,Y metric and get result example: 424846.43 205919.61 425005.55 205922.88 425742.99 205861.52
By Gilad on 01/02/2012
Did seem accurate showed the sea above sea level. number,latitude,longitude,meters,feet 0,-27.482852756907053,153.22373270988464,1.603,5.258
On 31/01/2012
First class I checked it against other known sources. They all agree
On 29/01/2012
OK I have a similar problem, I have KML of Hangliding locations, but want to determine their altitude AMSL & export info in CSV format so I can use it in XCSoar
By miles.hockliffe@edwardsvacuum. on 20/01/2012
works well, but one of my old work sites (Talasea in New Guinea) seems to have gone the way of the dodo.
By masta mak bipo iet on 13/01/2012
your coordinates are offset from google maps and the correct altitudes...tends to pull down and to the right about 100 to 200 ft on average
On 18/12/2011
works
On 18/12/2011
Ayeda Riaz, Unfortunately you cannot add locations.
By Daft Logic on 14/12/2011
draft logic made my assignment very easy and i m really glad. however, i do want to add an update at few locations but dont know how to do it. would someone be kind enough to guide me through that?
By Ayeda Riaz on 12/12/2011
Fantastic, Thank You
By Watermiller on 04/12/2011
Rashellet
On 26/11/2011
This map was not updated in August of 2011 as it states. I built a new house and cut my woods in September of 2010 and it doesn't show either.PLEASE UPDATE GEORGIA VT LIKE YOU ARE STATING STOP MISSREPRSENTING YOUR SITE.
On 21/11/2011
Criteria c=new Criteria(); c.setHorizontalAccuracy(500); c.setSpeedAndCourseRequired(true); LocationProvider lp=LocationProvider.getInstance(c); Location loc=lp.getLocation(60); QualifiedCoordinates qc=loc.getQualifiedCoordinates(); if(qc != null ) { lat = qc.getLatitude(); lon = qc.getLongitude(); alt = qc.getAltitude(); speed=loc.getSpeed(); System.out.println("LAT: " lat ", LON: " lon ", ALT: " alt ", SPD: " speed);
By Syed Nehal Ahmed (IUIC) on 12/11/2011
billb, There is a degree of error on the results returned.
By Daft Logic on 10/11/2011
Something seems incorrect in the altitude at 41.433539349627175,-89.39662890175629,224.902,737.866. This street intersection [Adams and Pearl]altitude says it is about 1 foot lower than the lot NE of that location. I know for a fact that the intersection is at least 2-3 feet HIGHER than the lot at 41.43367609177177,-89.3968649361496,224.991,738.160. WHAT GIVES?
By billb on 07/11/2011
Elevations appear to be from last survey sometime in the 70's (La).
On 05/11/2011
This works very well. Thank you so much.
By Noi on 01/11/2011
Works great from iPad. Thanks very much
On 31/10/2011
It's very good.thank you very much
By nopp on 29/10/2011
thanks a lot to the creator of this
On 27/10/2011
Chaiyavudh t. , it uses http://code.google.com/apis/maps/documentation/javascript/services.html#Elevation
By Daft Logic on 25/10/2011
If this is accurate, then I have found a new highest point in Oklahoma at number,latitude,longitude,meters,feet 0,36.931233201245,-103.0014696413536,1517.802,4979.664. Height being 1517.802 m / 4979.664 feet, which is a good 4 to 6 feet higher than official records.
By Rob on 23/10/2011
great tool, but how can we know that attitude is correct or trustable, so should declare reference sources
By Chaiyavudh t. on 20/10/2011
This program works quickly, but the output is frequently misleading if a coordinate is entered. That is because Google shifts the marker to the nearest road, which can be a significant distance away. An example is -31.79860, -69.29563, which displays a result of ~1900m, when the actual figure is ~2550m. The text box below shows the actual coordinates for the elevation displayed in red, but there is no warning that the results are for something other than the point entered.
On 19/10/2011
Works perfectly (Firefox 7.0.1, Ubuntu 10.04)
By Jakob on 17/10/2011
So good!
On 16/10/2011
i noticed there's a reset to zoom level 0 every time a zoom is made, e.g. you see the world again before moving from zoom level 4 to 5, 5 to 6, etc. this is quite jarring and i would think unnecessary, so be great to remove it. otherwise super helpful webpage and great service. thanks very much.
By lm on 10/10/2011
awsome
On 09/10/2011
I have checked the indicated OD against a known OD and found considerable error. This is great for a near OD but beware using it for other than general reference. The known OD I checked was Height 41.490m, Google Height shown = 43.485m. This accuracy is akin handheld GPS.
By Andrew Tizzard, Surveyor on 03/10/2011
Is there a stated margin of error, in distance in feet from actual location as per satelite birds eye, at the balloon point of notation? I am asking because I want to evaluate, prior to hiring for a elevation certificate. Accuracy matters.
On 03/10/2011

30 out of 198 comments shown. See all comments.

Add your own comment below and let others know what you think:

Comments :

Your Name (optional) :