Google Maps Find Altitude

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Projects Information Sandbox Software SignUp/In

DaftLogic>Sandbox>GoogleMapsFindAltitude

GoogleMapsFindAltitude
Determinethealtitude(elevation)whenapointistapped/clickedonamap

DropMarker?
SearchForLocation... Search
50m Mapdata2017Google

Lastpointclicked:47.83m/156.91feet

ClearMap

[MapHeight:SmallMediumLarge]

Output Outputinmeters? Outputinfeet? OutputDistance? Drawlinebetweenthemarkers?


latitude,longitude?
91,6.964044927140212,126.21511541772634,2317
101,6.963875863386457,126.21468358207494,2822
111,6.9636894938235105,126.21425711084157,3371
121,6.963517767517831,126.21382795739919,3965
131,6.963355359636,126.21339075732976,4606
141,6.963202270187715,126.21294953394681,5296
601,6.962269026678444,126.21366564184427,5913
761,6.962595798359331,126.2140737567097,6481
UploadandPlotAddresses
Pasteoneaddressperlinethenclick[Load].Thereisalimitof100rowsperbatch.Anyadditionalrowswillbeignored.

Load

Description
Useamaptodeterminingaltitude(elevation)whenapointistapped/clickedonamap.Youcanclick/tapadmanytimesasrequiredtofindtheelevationofmultiplepoints.
HowToUse
1. Clickonthemaponalocationwhereyouwishtofindthealtitude
2. Thealtitudewillbedisplayedinthemessageboxbelowthemapandwhenyouhoveroverthemarker
3. Youcanclicktoplacemorethanonemarkerandreturntohoverovereachinordertofindoutthealtitudeagain
4. Clickthe[ClearMap]buttoninordertoremoveallmarkersandstartagain
5. Usethesearchoptiontofindaplace
6. Clickonamarkertoremoveit

YoucanalsoaccessaCSVlistoflatitude,longitude,altitudeinmetersandaltitudeinfeetforeverymarkeryouplaceonthemap.

HowitWorks



varoutput_lat=newArray(0)
varoutput_lng=newArray(0)
varoutput_f=newArray(0)
varoutput_m=newArray(0)
varoutputDiv=document.getElementById('outputDiv')
varmap
varrouteMarkers=newArray(0)
varroutePoints=newArray(0)
vargeocoder
varlatlngbounds
varaddresslimit=100
varbool_toggle_draw_line=false
varlineWidth=1
varlineColor='#ff0066'
varroutePath

functioninitialize()
{
varlatlng=newgoogle.maps.LatLng(0,0)
//setCursor:'crosshair'
varmyOptions={zoom:1,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP,draggableCursor:'crosshair',mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_
map=newgoogle.maps.Map(document.getElementById("map_canvas"),myOptions)

//CreateElevationService
elevator=newgoogle.maps.ElevationService()

//AddalistenerfortheclickeventandcallgetElevationonthatlocation
google.maps.event.addListener(map,'click',mapclickedevent)

geocoder=newgoogle.maps.Geocoder()
latlngbounds=newgoogle.maps.LatLngBounds()
}

functionfoundsingle(first)
{
varlatlng=newgoogle.maps.LatLng(parseFloat(first.lat),parseFloat(first.lng))
varobj=newObject()
obj.latLng=latlng
getElevation(obj)
}

functionmapclickedevent(event)
{
getElevation(event.latLng)
}

functiongetElevation(clickedLocation)
{
varlocations=[]

locations.push(clickedLocation)

//CreateaLocationElevationRequestobjectusingthearray'sonevalue
varpositionalRequest={'locations':locations}

//Initiatethelocationrequest
elevator.getElevationForLocations(positionalRequest,function(results,status)
{
if(status==google.maps.ElevationStatus.OK)
{
//Retrievethefirstresult
if(results[0])
{
//Openaninfowindowindicatingtheelevationattheclickedposition
outputDiv.innerHTML="Lastpointclicked:"+results[0].elevation.toFixed(3)+"m/"+(results[0].elevation*3.2808399).toFixed(3)+"feet"

//addthemarker
varmarker=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="Noresultsfound"
}
}
else
{
outputDiv.innerHTML="Elevationservicefaileddueto:"+status
}
})
}

functionaddCloseEvent(marker,index){
marker.addListener('click',function(){
marker.setMap(null)

if(routeMarkers.length>1)
{
ftn_drawline()
}
else
{
//hidethepolyline
if(routePath)
routePath.setMap(null)
}
ftn_makecsv()
})
}

functionplaceMarker(location,text)
{
varimage='images/gmmarkersv3/stripes.png'
varmarker=newgoogle.maps.Marker({position:location,map:map,icon:image,title:text})
returnmarker
}

functionclearmap()
{
if(routeMarkers)
{
for(iinrouteMarkers)
{
routeMarkers[i].setMap(null)
}
}
routeMarkers=newArray(0)

if(routePath)
{
routePath.setMap(null)
}

outputDiv.innerHTML=""

latlngbounds=newgoogle.maps.LatLngBounds()

output_lat=newArray(0)
output_lng=newArray(0)
output_f=newArray(0)
output_m=newArray(0)

document.getElementById("ta_csvoutput").style.display="none"
document.getElementById("ta_csvoutput").value=""

document.getElementById("goto").value=""
document.getElementById("btn_go").value="Search"
}

functionftn_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+=",cumulativedistance(m)"
}
output+="\n"

varcumulativedistance=0

for(iinrouteMarkers)
{
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)
{
vartmp_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
}

functionsubmitenter(myfield,e)
{
varkeycode
if(window.event)keycode=window.event.keyCode
elseif(e)keycode=e.which
elsereturntrue

if(keycode==13)
{
ftn_quickfind(document.getElementById('goto').value)
document.getElementById("goto").focus()
document.getElementById("goto").select()
returnfalse
}
else
{
returntrue
}
}

functionftn_quickfind(address)
{
document.getElementById("btn_go").value="Searching..."
geocoder.geocode({'address':address},function(results,status)
{
if(status==google.maps.GeocoderStatus.OK)
{
varpoint=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="NotFound"
//console.log(address)
}
})
}

functionftn_zoomtofit()
{
map.setCenter(latlngbounds.getCenter())
map.fitBounds(latlngbounds)
}

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

functionnextaddress()
{
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++
}

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

functionftn_toggle_draw_line()
{
bool_toggle_draw_line=!bool_toggle_draw_line
ftn_drawline()
}

functionftn_drawline()
{
if(routePath)
routePath.setMap(null)

//rebuildroutePointsbasedonmarkerslocation
routePoints=newArray(0)
if(routeMarkers)
{
for(iinrouteMarkers)
{
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)
}
}

functiongetRoutePath()
{
varroutePath=newgoogle.maps.Polyline({
path:routePoints,
strokeColor:lineColor,
strokeOpacity:1.0,
strokeWeight:lineWidth,
geodesic:true
})
returnroutePath
}

RelevantLinks
GoogleMapsAPI
VersionHistory
Version1(28/09/2008)
Version1.1(28/12/2008)
Addedquickfindoption

Version1.2(21/03/2009)
Enlargedoutputtextatbottomofmap

Version1.3(04/12/2009)
Outputnowalsodisplayedinfeet

Version2.0(10/08/2010)
ImplementedGoogleMapsAPIV3
NowusestheGoogleMapsAPIElevationService

Version2.1(11/08/2010)
Addednewlocalsearchfacility
Broughtbackoutputinfeet

Version2.2(17/08/2010)
AddedoutputtoCSVoptiontoallowexportoflatitude,longitude,metersandfeet

Version2.3(31/08/2011)
Nowoutputsaltitudeimmediatlyfromasearch

Version2.4(07/10/2013)
Addedscalecontrol

Version2.4(10/11/2013)
RemovedGoogleLocalSearchAPI(Deprecated)
Version3.0(23/11/2013)Youarehere
AddedoptiontoUploadandPlotAddresseswiththeirelevation

Version3.1(26/10/2015)
Newoptiontodrawalinebetweenthemarkers

Version3.2(18/08/2016)
Cumulativedistanceisnowoutput

Version3.3(16/10/2016)
Clickingonanelevationmarkernowremovesit

CommentsForThisPage
HiBill,theelevationisbasedonmeansealevel,sowithoutknowexactlywhereyousampledtheelevation,thereisachancetheimageshowsthetidein.
ByDaftLogicon15thMay2017


whencheckingelevationsitseemsifyouselecttheheightoverwater,exampleinlongislandoffNewHaven/WestHavenCT.itshowsabout4.8feet.Ithoughtitwouldbezerountilonshore.
ByBillon14thMay2017

Hi,noitwouldbethegroundlevelelevationthatgetsestimated.
ByDaftLogicon2ndMay2017

WhenIclickonahouse,doesthealtitudeincludingheightofthehouse?

Thanks,
On1stMay2017
Greattool.Thanks!
On22ndApril2017

Hi,wedohavelimitsonthissharedservicesofromtimetotimethiswillhappen.Itwillrunagainthefollowingday.Wewillmonitorthistocheckthefrequencyofthismessage.
ByDaftLogicon16thFebruary2017

Hello,Greatsite,andveryhelpfulforourneedsbutnowIamalsobeingblockedfromusingtheprogramwithamessageof"Elevationservicefaileddueto:OVER_QUERY_LIMIT"Please
explain.Thanks.
On15thFebruary2017

WhatdoesthemessageOVER_QUERY_LIMITmean?
I'vebeenusingthiswebsitesuccessfullyformanymonthsbutnowgetthismessageeverytimeforwhateverTown/CityIinput.

Ciao

Peter
On15thFebruary2017

Hi,itusesWGS84[https://en.wikipedia.org/wiki/World_Geodetic_System]
ByDaftLogicon11thJanuary2017

Whatcoordinatesystemdoesthisprogramuse?e.g.WGS84,WGS84/UTMzone12N,WGS84/WorldMercator,etc.
IamusingthesecoordinatesasGroundControlPoints(GCPs)togeneratea3Dmap,soIneedthecoordinatesystemsotheprogramcaninterpretandplacethemcorrectly.
Thankyou.

On11thJanuary2017
Hi,canyougivesomemoredetailsplease?Whataretheissues?
ByDaftLogicon7thDecember2016

Unfortunatelythiswebpagedoesnotshowgeographicallocationsproperly.

On7thDecember2016

Hi,unfortunatelythereisnofiguretogiveyoutodefinetheaccuracy.Allthatcanbesaidisitisonlyanestimate.
ByDaftLogicon25thNovember2016

HelloDaftLogic,

Thanksforthetool,it'sgreat!
Iwouldneedtoestimatetheaccuracyoftheresult.HowcouldIgetthat?

Thanksforyouranswer,
Bestregards,

Baptiste
ByBaptisteon25thNovember2016

Phil,thishasnowbeenaddedasanewfeature
ByDaftLogicon16thOctober2016

Itwouldreallybenicetobeabletomoveand/orremoveadatapointwhenoneisaccidentallyplaced.

Thanksforthisapplication,itwillreallyhelpmewithmyproject.
ByPhilon15thOctober2016
ThisreallyhelpedwithmyGeologyproject.
ByMadion26thSeptember2016

Howaccurateisthisheightlevelmeasurement?
ByVickiHoustonon22ndAugust2016

Gary,thereisnowacumulativedistanceoutputonthispage.
ByDaftLogicon18thAugust2016

Iamconfusebecausethealtitudevaluegivenonaroadlevelisbiggerthenthatofahighergroundnexttotheroad.Pleaseadvice?
ByJohnon16thAugust2016

HeyDL,ItriedtheDistanceCalculatorbeforeaskingthequestionandit'sperfectwiththeoveralldistanceintheinputboxbutitdoesn'thavethelistofclickedmarkersinatextarealikeonthistool.
Haha.Sorry.
ByGaryon27thJuly2016

HiGary,thisismoreorlesswhattheDistanceCalculatordoes.HowevertheDistanceCalculatoralsohasa[ShowElevation]buttontoshowtheelevationsalongtheroutedrawn.
ByDaftLogicon26thJuly2016

Workingperfectlystill.Woulditbepossibletoaddadistancecalculationtotheoutputlist?
*Totaldistancealongthelinefrompoint1tothecurrentone.
Sothatbytheendofthelineyouknewthetotaldistancetravelled.
ByGaryon26thJuly2016

HiDamien,thisisthemostrelevantreferencehttps://groups.google.com/d/msg/googlemapsjsapiv3/KcjkSU36dE/PBIutsUl5WEJ
ByDaftLogicon12thJuly2016
HiDaftLogic,canyoupleasetellmewhatDatumandCoordinateSystemisusedorhowIcanfindthis?IsitWGS84?andwhatUTMzone(includingwhatEGMisused)?Iamusingmapping
softwareandthisinformationishardtofind.Thanks,Damien
ByDamienon11thJuly2016

Whereistheelevationinformationforthispagefrom?
On1stJune2016

seemstobejustincreasingtheelevationeachtimeIclick,nomatterwhereIclick...
On24thMay2016

canifindaltitude3yearsback???
On24thMay2016

Accuracyiswayoff.UsinganaddressgeolocationAPIIbelieve
ByDroneGuyon6thMay2016

Hithere,thanksfortheinformation.ButIwantgettheinfooftheheightofbuildings,howcanImarkapointandreadtheheightofbuildingonthatplace?Thx

Anyonecanmessagemetokexuu@icloud.com.Thankyou
ByDaveon13thApril2016

30outof461commentsshown.Seeallcomments.

Addyourowncommentbelowandletothersknowwhatyouthink:

Enteryourmessage
YourName(optional)

AddComment

ShareThisPage
Sharethispagewithothersusingoneofthemethodsbelow.TellingothersaboutDaftLogicisgoodandweappreciateyoursupport!

LiketheDaftLogicFacebookPage SearchDaftLogic

Search

ContactDaftLogic News Links


DaftLogic Disclaimer Sitemap(HTML/XML)

You might also like