Google Maps API Lat/Lon Lookup

This form and code do a Google Maps API lookup and parses the resulting XML to extract the formatted address and latitude and longitude of the address.

Address to Geocode
Latitude: 38.8987149
Longitude: -77.0376555

Negative Longitude = WEST
Negative Latitude = SOUTH


---------- COLDFUSION CODE TO IMPLEMENT GOOGLE MAPS API XML -------------------
<cfparam name="form.address" default="1600 Pennsylvania Avenue Northwest, Washington, DC 20500-0003 USA" />

<cfhttp url="http://maps.google.com/maps/api/geocode/xml" method="GET">
 <cfhttpparam type="FORMFIELD" name="address" value="#form.address#" />
 <cfhttpparam type="FORMFIELD" name="sensor" value="false" />
</cfhttp> 

<cfset myXMLDoc = XMLParse(cfhttp.fileContent) />


<form action="latlonlookup.cfm" method="post">

<cfoutput>
Address: <input type="Text" name="address" value="#myXMLDoc.GeocodeResponse.result.formatted_address.XmlText#" style="width:450px;font-size:0.8em;" onclick="this.value='';" /> <input type="Submit" value="Go" />

</form>
Latitude: #myXMLDoc.GeocodeResponse.result.geometry.location.lat.XmlText#<br />
Longitude: #myXMLDoc.GeocodeResponse.result.geometry.location.lng.XmlText#
</cfoutput>
4,064 page views

Tom Nunamaker's Blog Follow me on Twitter
Follow me on Twitter
.
I tweet about the Euro/USD and
Economic News related for traders.

Home  |   Email and Web Hosting  |   Lat/Lon Lookup  |   Link Builder  |   Math
Image Resizing Calculator  |   Naked Option Margin Calculator  |   Web Form Generator
Tweet This!  |   Webpage Title, Description and Keywords
Line Calculator  |  Build WebEx Event Email  |  .htaccess Generator
Longtail Video JW Player 5 Embed Code Generator  |  Spin Text Formatter
Make Your Email Address Web Safe  |  Mobile Website Viewer

Copyright © 1996-2012, All rights reserved. Tom Nunamaker