Google Maps Find Altitude

[Map Height : Small - Medium - Large]

Upload and Plot Addresses

Paste one address per line then click [Load]. There is a limit of 100 rows per batch. Any additional rows will be ignored.

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
  6. Click on a marker to remove it

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 output_lat =new Array(0);
var output_lng =new Array(0);
var output_f =new Array(0);
var output_m =new Array(0);
var outputDiv=document.getElementById('outputDiv');
var map;
var routeMarkers=new Array(0);
var routePoints=new Array(0);
var geocoder;
var latlngbounds;	
var addresslimit=100;
var bool_toggle_draw_line=false;
var lineWidth=1;
var lineColor='#ff0066';
var routePath;

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},scaleControl:true};
	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', mapclickedevent);
		  
	geocoder = new google.maps.Geocoder();	
	latlngbounds = new google.maps.LatLngBounds();
}

function foundsingle(first)
{
	var latlng = new google.maps.LatLng (parseFloat(first.lat),parseFloat(first.lng));
	var obj=new Object();
	obj.latLng=latlng;
	getElevation(obj);
}

function mapclickedevent(event)
{
	getElevation(event.latLng); 
}

function getElevation(clickedLocation) 
{
	var locations = [];
		
	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 / " + (results[0].elevation*3.2808399).toFixed(3) + " feet";
				
				//add the marker
				var marker=placeMarker(clickedLocation,results[0].elevation.toFixed(3) + " m / " + (results[0].elevation*3.2808399).toFixed(3) + " feet");
				marker.setMap(map);
				addCloseEvent(marker,routeMarkers.length);
				
				routeMarkers.push(marker);
				ftn_drawline();	
				
				latlngbounds.extend(clickedLocation);
				
				output_lat.push(clickedLocation.lat());
				output_lng.push(clickedLocation.lng());
				output_f.push((results[0].elevation*3.2808399).toFixed(3));
				output_m.push(results[0].elevation.toFixed(3));
				
				ftn_makecsv();
			} 
			else 
			{
				outputDiv.innerHTML="No results found";
			}
	  	} 
	  	else 
	  	{
			outputDiv.innerHTML="Elevation service failed due to: " + status;
		}
	});
}

function addCloseEvent(marker,index) {
  	marker.addListener('click', function() {
	marker.setMap(null);
		
	if (routeMarkers.length > 1)
	{
		ftn_drawline();
	}
	else
	{
		//hide the polyline
		if (routePath)
		routePath.setMap(null);
	}
	ftn_makecsv(); 
  });
}

function placeMarker(location,text) 
{
	var image = 'images/gmmarkersv3/stripes.png';
	var marker = new google.maps.Marker({position:location,map:map,icon:image,title:text});
	return marker;
}

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

	if (routePath)
	{
		routePath.setMap(null);
	}
	
	outputDiv.innerHTML="";
	
	latlngbounds = new google.maps.LatLngBounds();
	
	output_lat = new Array(0);
	output_lng = new Array(0);
	output_f = new Array(0);
	output_m = new Array(0);
	
	document.getElementById("ta_csvoutput").style.display="none";
	document.getElementById("ta_csvoutput").value="";
	
	document.getElementById("goto").value="";
	document.getElementById("btn_go").value="Search";
}

function ftn_makecsv()
{
	document.getElementById("ta_csvoutput").style.display="block";
	document.getElementById("ta_csvoutput").value="";
	
	output="number";
	if (document.getElementById("cb_output_latlng").checked)
	{
		output+=",latitude,longitude";
	}
	if (document.getElementById("cb_output_meters").checked)
	{
		output+=",meters";
	}
	if (document.getElementById("cb_output_feet").checked)
	{
		output+=",feet";
	}
	if (document.getElementById("cb_output_cumulativedistance").checked)
	{
		output+=",cumulative distance (m)";
	}
	output+="\n";
		
	var cumulativedistance=0;
	
	for (i in routeMarkers) 
	{
		if (routeMarkers[i].getMap())
		{
			
			output+=(i + 1);
			if (document.getElementById("cb_output_latlng").checked)
			{
				output+=","+output_lat[i]+","+output_lng[i];
			}
			if (document.getElementById("cb_output_meters").checked)
			{
				output+=","+output_m[i];
			}
			if (document.getElementById("cb_output_feet").checked)
			{
				output+=","+output_f[i];
			}
			if (document.getElementById("cb_output_cumulativedistance").checked)
			{
				var tmp_cumdist=google.maps.geometry.spherical.computeDistanceBetween(routeMarkers[0].getPosition(), routeMarkers[i].getPosition());
				cumulativedistance=parseInt(cumulativedistance) + parseInt(tmp_cumdist.toFixed(0));
				output+=","+cumulativedistance;
			}
			output+="\n";
		}
	}
	
	document.getElementById("ta_csvoutput").value=output;
}

function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)
	{
		ftn_quickfind(document.getElementById('goto').value);
		document.getElementById("goto").focus();
		document.getElementById("goto").select();
		return false;
	}
	else
	{
	   return true;
	}
}

function ftn_quickfind(address) 
{
	document.getElementById("btn_go").value="Searching...";
	geocoder.geocode( { 'address': address}, function(results, status) 
	{
		if (status == google.maps.GeocoderStatus.OK) 
		{
        	var point = results[0].geometry.location;
			if (document.getElementById("cb_dropmarker").checked)
			{
				getElevation(point);
			}
	
			map.setCenter(point);
			map.fitBounds(results[0].geometry.viewport);
			document.getElementById("btn_go").value="Found";  	
      	} 
		else 
		{
			document.getElementById("btn_go").value="Not Found";
			//console.log(address);
      	}
   	});
}

function ftn_zoomtofit()
{
	map.setCenter(latlngbounds.getCenter());
	map.fitBounds(latlngbounds);	
}

function ftn_processaddressupload(str_addresses)
{
	lines = str_addresses.split('\n');
	if (lines.length>addresslimit)
	{
		lines = lines.slice(0,addresslimit);
	}
	cnt=0;
	nextaddress();	
}

function nextaddress()
{
	if (cnt>=lines.length) 
	{
		document.getElementById("btn_ok").title="Complete!";
		ftn_zoomtofit();
		//$.unblockUI(); 
		return;
	}	
	else
	{
		document.getElementById("btn_ok").title="Processed "+(cnt+1)+"/"+lines.length;
	}
	ftn_geocodeaddress(lines[cnt],getElevation);
	cnt++;
}

function ftn_geocodeaddress(address, callbackFunction) 
{
	geocoder.geocode( { 'address': address}, function(results, status) 
	{
		if (status == google.maps.GeocoderStatus.OK) 
		{
			var point = results[0].geometry.location;
			callbackFunction(point);
			nextaddress();
		}
		else
		{
			alert("Address ("+address+")not found!");
			nextaddress();
		}
	});
}

function ftn_toggle_draw_line()
{
	bool_toggle_draw_line=!bool_toggle_draw_line;
	ftn_drawline();	
}

function ftn_drawline()
{
	if (routePath)
	routePath.setMap(null);
	
	//rebuild routePoints based on markers location
	routePoints=new Array(0);
	if (routeMarkers) 
	{
		for (i in routeMarkers) 
		{
			if (routeMarkers[i].getMap())
			{
				routePoints.push(routeMarkers[i].getPosition());
			}
		}
	}
	
	if ((bool_toggle_draw_line)&&(routePoints.length>1))
	{
		routePath=getRoutePath();
		routePath.setMap(map);
	}
	else
	{
		if (routePath)
		routePath.setMap(null);
	}	
}

function getRoutePath()
{
	var routePath = new google.maps.Polyline({
		path: routePoints,
		strokeColor: lineColor,
		strokeOpacity: 1.0,
		strokeWeight: lineWidth,
		geodesic: true
	});
	return routePath;
}

Relevant Links

Google Maps API

Version History

  • Version 1 (28/09/2008)
  • Version 1.1 (28/12/2008)
    • Added quick find option
  • Version 1.2 (21/03/2009)
    • Enlarged output text at bottom of map
  • Version 1.3 (04/12/2009)
    • Output now also displayed in feet
  • Version 2.0 (10/08/2010)
  • Version 2.1 (11/08/2010)
    • Added new local search facility
    • Brought back output in feet
  • Version 2.2 (17/08/2010)
    • Added output to CSV option to allow export of latitude, longitude, meters and feet
  • Version 2.3 (31/08/2011)
    • Now outputs altitude immediatly from a search
  • Version 2.4 (07/10/2013)
    • Added scale control
  • Version 2.4 (10/11/2013)
    • Removed Google Local Search API (Deprecated)
  • Version 3.0 (23/11/2013) - You are here
    • Added option to Upload and Plot Addresses with their elevation
  • Version 3.1 (26/10/2015)
    • New option to draw a line between the markers
  • Version 3.2 (18/08/2016)
    • Cumulative distance is now output
  • Version 3.3 (16/10/2016)
    • Clicking on an elevation marker now removes it

Comments For This Page

Hi, unfortunately there is no figure to give you to define the accuracy. All that can be said is it is only an estimate.
By Daft Logic on 25th November 2016
Hello Daft Logic,

Thanks for the tool, it's great !
I would need to estimate the accuracy of the result. How could I get that ?

Thanks for your answer,
Best regards,

Baptiste
By Baptiste on 25th November 2016
Phil, this has now been added as a new feature
By Daft Logic on 16th October 2016
It would really be nice to be able to move and/or remove a data point when one is accidentally placed.

Thanks for this application, it will really help me with my project.
By Phil on 15th October 2016
This really helped with my Geology project.
By Madi on 26th September 2016
How accurate is this height level measurement?
By Vicki Houston on 22nd August 2016
Gary, there is now a cumulative distance output on this page.
By Daft Logic on 18th August 2016
I am confuse because the altitude value given on a road level is bigger then that of a higher ground next to the road. Please advice?
By John on 16th August 2016
Hey DL, I tried the Distance Calculator before asking the question and it's perfect with the overall distance in the inputbox but it doesn't have the list of clicked markers in a textarea like on this tool. Haha. Sorry.
By Gary on 27th July 2016
Hi Gary, this is more or less what the Distance Calculator does. However the Distance Calculator also has a [Show Elevation] button to show the elevations along the route drawn.
By Daft Logic on 26th July 2016
Working perfectly still. Would it be possible to add a distance calculation to the output list?
*Total distance along the line from point 1 to the current one.
So that by the end of the line you knew the total distance travelled.
By Gary on 26th July 2016
Hi Damien, this is the most relevant reference - https://groups.google.com/d/msg/google-maps-js-api-v3/KcjkS-U36dE/PBIutsUl5WEJ
By Daft Logic on 12th July 2016
Hi Daft Logic, can you please tell me what Datum and Coordinate System is used or how I can find this? Is it WGS84? and what UTM zone (including what EGM is used)? I am using mapping software and this information is hard to find. Thanks, Damien
By Damien on 11th July 2016
Where is the elevation information for this page from?
On 1st June 2016
seems to be just increasing the elevation each time I click, no matter where I click...
On 24th May 2016
can i find altitude 3 years back???
On 24th May 2016
Accuracy is way off. Using an address geolocation API I believe
By DroneGuy on 6th May 2016
Hi there, thanks for the information. But I want get the info of the height of buildings, how can I mark a point and read the height of building on that place? Thx

Anyone can message me to kexuu@icloud.com. Thank you
By Dave on 13th April 2016
Hi Simon, the reason for this is likely to be the address upload is searching for address locations nearby such as a road or building rather than the precise location you give. So it is doing a disfavor by doing an address search rather than plotting the exact location.
By Daft Logic on 29th March 2016
This is a great piece of software, just one problem, if i copy and paste back in the lat/long co-ordinates and 'load' the location again, it shifts the location for each set of co-ordinates from the original !
By Simon on 28th March 2016
Including the output of Degrees would be great!
On 18th March 2016
Hi malcolm, lat,lng per line should work. For example:

48.4170371,2.5922382

48.1763093,2.961972

48.1671508,3.3986785
By Daft Logic on 15th February 2016
This is an excellent tool. One issue that I have is trying to get the altitude from a list of GPS longitude and latitude coordinates from a route. Can such a list be uploaded as "addresses"? What is the required list format?
By malcolm on 15th February 2016
SOOOOO great... thank you!
On 14th February 2016
Excellent tool. Thanks.

You call it Find Altitude but actually it is finding elevation.

"Altitude: Vertical distance between an object and the local surface of the Earth.

Elevation: Vertical distance between the local surface of the Earth and global sea level."
By Marco on 12th February 2016
Hi, please try the coordinates in the format latitude,longitude. E.g. 48.8583701,2.2944813 for the Eiffel Tower.
By Daft Logic on 8th February 2016
Tried pasting 4339%u203223%u2033N 7016%u203238%u2033W into the search bar and it came back "Not Found". I recall being able to paste coordinates in this format in previous versions. Aside from that, LOVE this tool.
On 6th February 2016
1 ) you need to put some distance between the figures you display for point number, lat, long, elevation.
2) You need to say what kind of distance the elevation data is averaged over. I wanted to find the elevation of a river - I put down several markers in the flat-surfaced river and they came back with a 2 metre spread of elevation. I know you're just reporting what Google tells you but a guide to the limitations of the tool would be helpful.
By Mi Wu on 2nd February 2016
Hi, looking at Lake Pontchartrain, I get results below zero. Could you try again and see if it does anything different?
By Daft Logic on 20th January 2016
nice work! I don't see the negative values around lake ponchartrain in New Orleans, just down to zero.
On 20th January 2016

30 out of 449 comments shown. See all comments.

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

Share This Page

Share this page with others using one of the methods below. Telling others about Daft Logic is good and we appreciate your support!