I tried putting this in the Script forum but it wouldn't let me add a new topic. I tried in IE and FF.
I could have sworn I saw a script that does geocoding but do not see it now.
Has anyone created a script to do geocoding? I want to pass address and get back the latitude and longitude of the address.
Thanks
Alan
Geocoding/Geocode
Moderators: Dorian (MJT support), JRL
Never tried this before but based on the information on THIS page, wrote this line:
Which, when run, resulted in this output:
Just a matter of parsing after that.
You do need to read the usage limits:
Code: Select all
HTTPRequest>http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway%comma%+Mountain+View%comma%+CA&sensor=true,,get,,resvar,,,,
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>1600 Amphitheatre Parkway, Mountain View, CA 94043, USA</formatted_address>
<address_component>
<long_name>1600</long_name>
<short_name>1600</short_name>
<type>street_number</type>
</address_component>
<address_component>
<long_name>Amphitheatre Parkway</long_name>
<short_name>Amphitheatre Pkwy</short_name>
<type>route</type>
</address_component>
<address_component>
<long_name>Mountain View</long_name>
<short_name>Mountain View</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Santa Clara</long_name>
<short_name>Santa Clara</short_name>
<type>administrative_area_level_2</type>
<type>political</type>
</address_component>
<address_component>
<long_name>California</long_name>
<short_name>CA</short_name>
<type>administrative_area_level_1</type>
<type>political</type>
</address_component>
<address_component>
<long_name>United States</long_name>
<short_name>US</short_name>
<type>country</type>
<type>political</type>
</address_component>
<address_component>
<long_name>94043</long_name>
<short_name>94043</short_name>
<type>postal_code</type>
</address_component>
<geometry>
<location>
<lat>37.4221001</lat>
<lng>-122.0860225</lng>
</location>
<location_type>ROOFTOP</location_type>
<viewport>
<southwest>
<lat>37.4207511</lat>
<lng>-122.0873715</lng>
</southwest>
<northeast>
<lat>37.4234491</lat>
<lng>-122.0846735</lng>
</northeast>
</viewport>
</geometry>
</result>
</GeocodeResponse>
You do need to read the usage limits:
Google web page wrote:Usage Limits
Use of the Google Geocoding API is subject to a query limit of 2,500 requests per day. (User of Google Maps API for Business may perform up to 100,000 requests per day.) This limit is enforced to prevent abuse and/or repurposing of the Geocoding API, and this limit may be changed in the future without notice. Additionally, we enforce a request rate limit to prevent abuse of the service. If you exceed the 24-hour limit or otherwise abuse the service, the Geocoding API may stop working for you temporarily. If you continue to exceed this limit, your access to the Geocoding API may be blocked.
Note: the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.