Getting Region Data of geolocation using Google Maps API
Is there an easy way to determine a point's region in the world based on it's latitude and longitude?
I have an entry form that开发者_如何学编程 a user enters in their address (city, state, and country). I then geocode this into a point that I can use on a Google Map.
However, I'd like to have it store the region of the point as well so I can use it for filtering the entry (North America, South America, Asia, Europe, Africa, Australia).
Is there a way to use the Google Maps API to determine the region of a geolocation?
The Google Geocoder returns the country
. Example:
<Country>
<CountryNameCode>US</CountryNameCode>
<AdministrativeArea>
<AdministrativeAreaName>CA</AdministrativeAreaName>
<SubAdministrativeArea>
<SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName>
...
mapping countries to regions should be easy or easier to do.
Here is a list that would need some manual work: Countries by region
You may find a pre-filled table with ISO code to region mappings with some searching.
精彩评论