Geolocation - API Client JS
MapTiler API Client JS geolocation function provides an accurate location of a website visitor using its IP address.
Obtain information about visitor’s location based on the IP address of an incoming request.
// in an async function, or as a 'thenable':
const result = await maptilerClient.geolocation.info();
Parameters
options.apiKey | Custom MapTiler Cloud API key to use instead of the one in global config .
|
---|
Response
Returns a geolocation result object
{
"country": "Switzerland",
"country_code": "CH",
"country_bounds": [5.95538, 45.818852, 10.490936, 47.809357],
"country_languages": ["de", "fr", "it"],
"continent": "Europe",
"continent_code": "EU",
"eu": false,
"city": "Zurich",
"latitude": 47.36667,
"longitude": 8.55,
"postal": "8000",
"region": "Zurich",
"region_code": "ZH",
"timezone": "Europe/Zurich"
}
Read more about geolocation on our official API documentation.