Elemental lowcode development platform.
The location service provides methods that allow you to determine geographic information about a user. It supports the following methods:
These methods are covered in more detail below.
Parameters:
ip
- the ipv4/ipv6 to query for geographic detailsLooks up the geographic details for the given IP address. This method is async.
If no details can be found for the IP then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.details = await this.locationService.geographicDetails(this.context.client.ip);
}
}
};
Parameters:
ip
- the ipv4/ipv6 to determine the country forLooks up the country for the given IP address. This method is async.
If a country cannot be found for the IP then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.country = await this.locationService.determineCountry(this.context.client.ip);
}
}
};
Parameters:
ip
- the ipv4/ipv6 to determine the region forLooks up the region for the given IP address. This method is async.
If a region cannot be found for the IP then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.region = await this.locationService.determineRegion(this.context.client.ip);
}
}
};
Parameters:
ip
- the ipv4/ipv6 to determine the city forLooks up the city for the given IP address. This method is async.
If a city cannot be found for the IP then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.city = await this.locationService.determineCity(this.context.client.ip);
}
}
};
Parameters:
ip
- the ipv4/ipv6 to determine the latitude/longitude forLooks up the lat/lon for the given IP address. This method is async.
If a lat/lon cannot be determined the IP then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.latlon = await this.locationService.determineLatLon(this.context.client.ip);
console.log(this.bag.latlon) // outputs : { "lat" : 12.345, "lon" : 12.234 }
}
}
};
Parameters:
ip
- the ipv4/ipv6 to determine the timezone forLooks up the timezone for the given IP address. This method is async.
If a timezone cannot be determined the IP then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.timezone = await this.locationService.determineTimezone(this.context.client.ip);
}
}
};
Parameters:
ip
- the ipv4/ipv6 to checkDetermines if the IP address is within the EU (or another GDPR compliant country). This method is async.
If this cannot be determined for the IP address then this method will resolve a null value.
This can be called from your controllers like so:
module.exports = {
events : {
load : async function(event) {
this.bag.fromEU = await this.locationService.isFromEU(this.context.client.ip);
}
}
};