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

Hi Bob, you can try the [Upload and Plot Addresses] text box. Paste the rows in seperatley and click Load.
By Daft Logic on 24/08/2015
Hi, thanks a lot for this great job. I still have a question. If I have a long list of (lat,lon) in excel, how can I generate the height. It is not possible to click them individually. Thanks in advance.
By Bob on 24/08/2015
Great, Very useful, how can we customize this to find low lying areas??
By Sharan on 16/08/2015
excellent! thank you for this useful application!
On 16/08/2015
I used this app to calibrate my tourist meteo station with builtin altimeter. This site gave me the easiest way to find the altitude to set up the starting point's height.
By Thomasso on 04/08/2015
Junction Road Jeeralang Junction Victoria Australia
On 02/08/2015
Merci beaucoup pour votre outil, vraiment très pratique.
By Eric Choppinet on 24/07/2015
Cool
By Bill J on 16/07/2015
I love this tool, thank you for creating it.
By Anna on 16/07/2015
very handy!
By Nick on 13/07/2015
Very useful. Thank you very much.
On 13/07/2015
Tool is useful, layout of the page is overlapping in the most convenient and Irritating way, so I give up trying to get the stupid right hand side ad banner, out of the way and will go to another site that will work
By Anonymous on 04/07/2015
how to find building height
On 29/06/2015
GREAT
On 26/06/2015
Thanks to DaftLogic Team for their answers about maximum absolute error and reference level. Regards
By Gennaro Reppucci g.reppucci@ti on 05/06/2015
Thanks for providing this site. It's a life saver. Literally.
By Sue Jeep on 05/06/2015
I would be great if the image had a grid system at 10 ft and I could be aligned with the property lines.
By Gabriel on 01/06/2015
Hi Gennaro, sorry we cannot give any exact answer to those questions. The best is a)its an estimate and 2) from mean sea level
By Daft Logic on 25/05/2015
Indeed a very useful tool ! Just two issues: A) is it possible to have the maximum absolute error on altitude values? B) is it possible to have an unambiguous definiton of the reference level? Thank you
By Gennaro Reppucci g.reppucci@ti on 25/05/2015
great software...very usefull.
By Kakuro on 24/05/2015
Hi, zero is mean sea level. There is no figure for the degree of accuracy except to say it is an Estimation.
By Daft Logic on 26/04/2015
Hi, How zero level is defined? And what is the (standard) error of the figures? Estimation? Guestimation? Cheers
On 24/04/2015
Great Software. Have been playing with it for a while. Wish I could delete some bubbles by right clicking it. Was trying to create contour lines for my farm. Wish after I find a contour could draw a line, and save it and print it. Best
By Balaji on 06/04/2015
Just what I needed. Thanks!
On 04/04/2015
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

30 out of 390 comments shown. See all comments.

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

Comments :

Your Name (optional) :