Since Google requires recently to add your key to API uses, I have a problem to get it run on a script that was calculating distances properly before. In my code I have this:
<cfhttp url="http://maps.googleapis.com/maps/api/geocode/xml" method="GET">
so if I add the API key like this (according to official documentation):
<cfhttp url="http://maps.googleapis.com/maps/api/geocode/xml?key=MyKeyGoesHere" method="GET">
ColdFusion is telling me there is an error:
Element GEOCODERESPONSE.RESULT.GEOMETRY.LOCATION.LAT.XMLTEXT is undefined in MYXMLDOC.
I got the same error message, when I tried to add the key via cfhttpparam:
<cfhttpparam type="FORMFIELD" name="key" value="MyKeyGoesHere" />
Here is the relevant part of the script without API key:
<cfset address = '#usersearch#, DE'>
<cfhttp url="http://maps.googleapis.com/maps/api/geocode/xml" method="GET">
<cfhttpparam type="FORMFIELD" name="address" value="#address#" />
<cfhttpparam type="FORMFIELD" name="sensor" value="false" />
</cfhttp>
<cfset myXMLDoc = XMLParse(cfhttp.fileContent) />
<cfif myXMLDoc contains 'ZERO_RESULTS' or myXMLDoc contains 'OVER_QUERY_LIMIT'>
We have encountered an error, please contact the webmaster
<cfelse>
<cfset latitude = '#myXMLDoc.GeocodeResponse.result.geometry.location.lat.XmlText#'>
<cfset longitude = '#myXMLDoc.GeocodeResponse.result.geometry.location.lng.XmlText#'>
I don't know where else to set the API key...?