Skip to content

Geolocation Functions

GeoHashDecode

returns the latitude and longitude for a given geo hash string

Syntax:

GeoHashDecode(hash string) -> (lat:number, lng:number)

Examples:

GeoHashDecode("8675309").lat = 13.231
GeoHashDecode("8675309").lng = -164.485

GeoHashEncode

returns the string geohash for a given latitude and longitude

Syntax:

GeoHashEncode(lat number, lng number) -> string

Examples:

GeoHashEncode(34.0901, -118.4065) = "9q5cctgj0x4r"

GeoMiles

returns the miles between two lat/lng coordinates

Syntax:

GeoMiles(lat1 number, lng1 number, lat2 number, lng2 number) -> number

Examples:

GeoMiles(41.5,87.37, 40.47, 73.58) = 721.8461040487858
GeoMiles(-34, 151, -36.52, 174.45) = 1330.7963962578674

IPCity

returns the city for a given IP address

Syntax:

IPCity(ip string) -> string

Examples:

IPCity("202.162.192.8") = "Los Angeles"
IPCity("0") is null

IPCountry

returns the country code for a given IP address

Syntax:

IPCountry(ip string) -> string

Examples:

IPCountry("202.162.192.8") = "US"
IPCountry("0") is null

IPLocate

returns the latitude and longitude for a given IP address

Syntax:

IPLocate(ip string) -> (lat:number, lng:number)

Examples:

IPLocate("202.162.192.8") = 3.5847, 98.6629
IPLocate("0") = null, null

IPRegion

returns the region (state) for a given IP address

Syntax:

IPRegion(ip string) -> string

Examples:

IPRegion("202.162.192.8") = "California"
IPRegion("0") is null