Logic, but in a different way

Daft Logic

Google Maps Find Altitude

Last Updated 23th November 2013

Search For Location : Drop Marker?

[Map Height : Small - Medium - Large]

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

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

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 geocoder;

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', getElevation);

geocoder = new google.maps.Geocoder();
}

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 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 / " + (results[0].elevation*3.2808399).toFixed(3) + " feet";
var marker=placeMarker(clickedLocation,results[0].elevation.toFixed(3) + " m / " + (results[0].elevation*3.2808399).toFixed(3) + " feet");
marker.setMap(map);
routeMarkers.push(marker);

output_lat.push(event.latLng.lat());
output_lng.push(event.latLng.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 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);
clearsearchresults();
document.getElementById("queryInput").value="";
outputDiv.innerHTML="";

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.visibility="hidden";
document.getElementById("ta_csvoutput").value="";
}

function ftn_makecsv()
{
var int=0;
document.getElementById("ta_csvoutput").style.visibility="visible";
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";
}
output+="\n";


for (i in routeMarkers)
{
output+=int;
if (document.getElementById("cb_output_latlng").checked)
{
output+=","+output_lat[int]+","+output_lng[int];
}
if (document.getElementById("cb_output_meters").checked)
{
output+=","+output_m[int];
}
if (document.getElementById("cb_output_feet").checked)
{
output+=","+output_f[int];
}
output+="\n";
int=int+1;
}
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_quickfind2(document.getElementById('goto').value);
document.getElementById("goto").focus();
document.getElementById("goto").select();
return false;
}
else
{
return true;
}
}

//***********************************************************************
//*****************Quick Find Option*************************************

function ftn_quickfind2(address)
{
document.getElementById("btn_go").value="Searching...";
geocoder.geocode( { 'address': address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
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 point = results[0].geometry.location;

map.setCenter(point);
map.fitBounds(results[0].geometry.viewport);

document.getElementById("btn_go").value="Found";
}
else
{
//alert("Geocode was not successful for the following reason: " + status);
document.getElementById("btn_go").value="Not Found";
}
});
}

Relevant Links

Google Maps API

Version History

Previous Comments For This Page

Thanks. Great app. Is there a better icon than the balloon? A small and concentric icon would make it easier to see spot locations, especially with more than one icon on the map.
By Karl Blette on 28/03/2015
Hi! Why is that everytime I place an address and try to load it, it show something else and not my address?
By John on 03/03/2015
Thanks.. very useful
By sangeeta gupta on 27/02/2015
What is the vertical datum?
By Joe on 25/02/2015
Hi mona, I'm not sure what you mean?
By Daft Logic on 24/02/2015
How do you find elevation requirements?
By mona on 20/02/2015
for some reason I can't scroll on the map nor does it search for places???
By David on 19/02/2015
Hi Mike, I'm not sure. This page only provides an estimate for current elevation.
By Daft Logic on 15/02/2015
How could I check the elevation of a street back in 2004? The street in Badlwin, N.Y. was raised in 2005.
By Mike on 12/02/2015
Hi Alberto, In answer to your questions 1) This is not possible on this page 2) We do not specify accuracy. All we can say is it is an estimate. 3) I believe its EPSG3857
By Daft Logic on 11/02/2015
Sir, v. useful application. Can I ask how to find the: 1. altitide of a location knowing the location in decimal degress, or other units? 2. What is the accuracy of the altitude measurement? What is the map reference system you use? eg. UTM, Thanks. Great work.
By Alberto Paludetto on 10/02/2015
This beats all other sites that 'claim' to calculate elevation of various locations ... Just what I needed and easy to use.
By C. Appleton on 23/01/2015
Very useful - and many thanks for the program!
On 22/01/2015
Great site thank you.
By crazy canner on 16/01/2015
Hi, its the land.
By Daft Logic on 26/12/2014
Is the elevation the elevation of the land or of the house on top of the land?
On 26/12/2014
Great program, and wonderful site! I'm looking for a house that needs to be around 70-150 masl (for my highland plants) and this program has helped by threshing out the unsuitable lowland areas, thus narrowing my search. Thanks!!!
By RixP on 18/12/2014
this is great program it is very useful tool thanku
On 14/12/2014
Can't use to many adds blocking page
On 06/12/2014
It's not perfect, but I find it very useful.
By LJ on 03/12/2014
Hi, try Google Maps To Send a Position.
By Daft Logic on 19/11/2014
Great program. All I want to know is how to get a specific url for a specific point on the map.
On 18/11/2014
Thanks a lot, it is great useful site
By Sarkis P K on 31/10/2014
Thanks a loooot, needed info for architecture project in France as a student, great job
On 15/10/2014
I could previously use this site, but now the map does not display. I'm using OSX Version 10.9.5 and Safari Version 7.1
On 04/10/2014
Your Website is extremely useful.But, as humans, I hope it is not true, you are actually not generous: Why do you block the access of your site to some countries!
By Batman on 02/10/2014
I guess it gives "approximate" data at best, not to be used for any scientific purposes where accuracy is key. I just viewed a location that I know for a fact is higher than another location next to it, but the elevation shown between the two is inaccurate. The two locations I viewed are about 100 meters apart and the one that's higher by a good few meters shows as being 0.020 meters lower. Unfortunately, that's simply impossible.
By Mr. Googler on 22/09/2014
Chris C., honest answer, I'm not sure.
By Daft Logic on 21/09/2014
Does this take into account the geoid variations?
By Chris C. on 20/09/2014
thank you so much. It is very useful for me!
On 15/09/2014

30 out of 366 comments shown. See all comments.

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

Comments :

Your Name (optional) :