문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top