Skip to content Skip to sidebar Skip to footer

How Can I Get The Country And Region Code Using Geolocation Instead Of Full Country And Region Names

I'm building a website that uses geolocation in HTML5 to provide a service specific to the region in which the user is. Here is what I have been doing: I use the Javascript in this

Solution 1:

You should use the short_name value for the country, which is the two-digit country code. These are ISO standard codes and should be the basis for your database lookup, not the localized country name.

Solution 2:

Another options, which has ISO codes for administrative regions, is MaxMind's GeoIP2 JavaScript API:

http://dev.maxmind.com/geoip/geoip2/javascript/

It uses W3C geolocation when available and falls back on MaxMind's IP geolocation database otherwise. The free version requires attribution somewhere on your site.

Post a Comment for "How Can I Get The Country And Region Code Using Geolocation Instead Of Full Country And Region Names"