WGS84GeoURL

WGS84GeoURL

URL interface for WGS84 geo URI with latitude, longitude and possibly altitude

Constructor

new WGS84GeoURL(url, baseopt)

Description:
  • Create a WGS84GeoURL from a string

    Limited to WGS84 URIs, which lets interpret them as containing latitude/longitude/altitude. But that's almost all of the geo URIs because no other CRS is currently supported by RFC 5870.

Source:
See:
  • MDN for URL constructor
Parameters:
Name Type Attributes Description
url string | URL | GeoURL

geo URI or relative reference

base string | URL | GeoURL <optional>

base geo URI

Extends

Classes

WGS84GeoURL

Members

CRS :string

Description:
  • Coordinate reference system

    An alternative name for GeoURL#crs

Source:
Overrides:

Coordinate reference system

An alternative name for GeoURL#crs

Type:
  • string

alt :number|undefined

Description:
  • Altitude in meters

Source:
See:

Altitude in meters

Type:
  • number | undefined
Examples
const url = new WGS84GeoURL("geo:13.4125,103.8667")
console.log(url.alt) // outputs "undefined"
const url = new WGS84GeoURL("geo:48.201,16.3695,183")
console.log(url.alt) // outputs "183"

altitude :number|undefined

Description:
Source:

Altitude in meters

A longer name for WGS84GeoURL#alt

Type:
  • number | undefined

coordA :number

Description:
  • 1st coordinate in an arbitrary CRS

Source:
Overrides:

1st coordinate in an arbitrary CRS

Type:
  • number
Example
const url = new GeoURL("geo:60,30")
console.log(url.coordA) // outputs "60"

coordB :number

Description:
  • 2nd coordinate in an arbitrary CRS

Source:
Overrides:

2nd coordinate in an arbitrary CRS

Type:
  • number
Example
const url = new GeoURL("geo:60,30")
console.log(url.coordB) // outputs "30"

coordC :number|undefined

Description:
  • 3rd coordinate in an arbitrary CRS, possibly undefined

Source:
Overrides:

3rd coordinate in an arbitrary CRS, possibly undefined

Type:
  • number | undefined
Examples
const url = new GeoURL("geo:60,30")
console.log(url.coordC) // outputs "undefined"
const url = new GeoURL("geo:60,30,5")
console.log(url.coordC) // outputs "5"

coordinates :Array.<number>

Description:
  • Coordinates array

Source:
Overrides:

Coordinates array

Type:
  • Array.<number>
Example
const url = new GeoURL("geo:60,30;u=10")
console.log(url.coordinates) // outputs "[ 60, 30 ]"

coordinatesString :string

Description:
  • Coordinates as a string of two or three comma-separated numbers, as they appear in the URL.

Source:
Overrides:

Coordinates as a string of two or three comma-separated numbers, as they appear in the URL.

Type:
  • string
Example
const url = new GeoURL("geo:60,30;u=10")
console.log(url.coordinatesString) // outputs "60,30"

crs :string

Description:
  • Coordinate reference system

    Converted to lowercase if present in the URL.

    Has the default value of wgs84 if not present.

Source:
Overrides:

Coordinate reference system

Converted to lowercase if present in the URL.

Has the default value of wgs84 if not present.

Type:
  • string

(readonly) geoParams :GeoParams

Description:
  • geo URI parameters object

    The returned object will throw a TypeError if the "crs" parameter is updated to anything other than "wgs84", case-insensitively.

Source:
Overrides:

geo URI parameters object

The returned object will throw a TypeError if the "crs" parameter is updated to anything other than "wgs84", case-insensitively.

Type:

hash :string

Description:
  • Hash property containing the fragment identifier

Source:
Overrides:
See:
  • MDN for hash property

Hash property containing the fragment identifier

Type:
  • string

lat :number

Description:
  • Latitude in decimal degrees between -90 and 90

Source:
See:

Latitude in decimal degrees between -90 and 90

Type:
  • number
Example
const url = new WGS84GeoURL("geo:13.4125,103.8667")
console.log(url.lat) // outputs "13.4125"

latLng :Array.<number>

Description:
Source:

Latitude-longitude pair

An alternative name for WGS84GeoURL#latLon, favored by Leaflet

Type:
  • Array.<number>
Example
const url = new WGS84GeoURL("geo:13.4125,103.8667")
L.marker(url.latLng)

latLon :Array.<number>

Description:
  • Latitude-longitude pair

Source:

Latitude-longitude pair

Type:
  • Array.<number>

latitude :number

Description:
  • Latitude in decimal degrees between -90 and 90

    A longer name for WGS84GeoURL#lat

Source:

Latitude in decimal degrees between -90 and 90

A longer name for WGS84GeoURL#lat

Type:
  • number

lng :number

Description:
  • Longitude in decimal degrees between -180 and 180

    An alternative name for WGS84GeoURL#lon, as used for example in Leaflet

Source:

Longitude in decimal degrees between -180 and 180

An alternative name for WGS84GeoURL#lon, as used for example in Leaflet

Type:
  • number

lngLat :Array.<number>

Description:
Source:

Longitude-latitude pair

An alternative name for WGS84GeoURL#lonLat

Type:
  • Array.<number>

lon :number

Description:
  • Longitude in decimal degrees between -180 and 180

Source:
See:

Longitude in decimal degrees between -180 and 180

Type:
  • number
Example
const url = new WGS84GeoURL("geo:13.4125,103.8667")
console.log(url.lon) // outputs "103.8667"

lonLat :Array.<number>

Description:
  • Longitude-latitude pair

    The order is swapped as compared with the URI and WGS84GeoURL#latLon

Source:

Longitude-latitude pair

The order is swapped as compared with the URI and WGS84GeoURL#latLon

Type:
  • Array.<number>

longitude :number

Description:
  • Longitude in decimal degrees between -180 and 180

    A longer name for WGS84GeoURL#lon

Source:

Longitude in decimal degrees between -180 and 180

A longer name for WGS84GeoURL#lon

Type:
  • number
Description:
  • Search/query string

Source:
Overrides:
See:
  • MDN for search property

Search/query string

Type:
  • string

(readonly) searchParams :URLSearchParams

Description:
  • URLSearchParams object

Source:
Overrides:
See:
  • MDN for searchParams property

URLSearchParams object

Type:
  • URLSearchParams

u :number|undefined

Description:
  • Uncertainty in meters

    Equals to undefined for missing u geo parameter. Setting to undefined deletes the parameter. Setting keeps the number up to a nanometer precision.

Source:
Overrides:
See:

Uncertainty in meters

Equals to undefined for missing u geo parameter. Setting to undefined deletes the parameter. Setting keeps the number up to a nanometer precision.

Type:
  • number | undefined

uncertainty :number|undefined

Description:
  • Uncertainty in meters

    A longer name for GeoURL#u

Source:
Overrides:

Uncertainty in meters

A longer name for GeoURL#u

Type:
  • number | undefined

z :number|undefined

Description:
  • Zoom level

    Equals to undefined for missing z search parameter. Numeric precision is the same as when setting GeoURL#u because Google documentation doesn't specify it.

    Example values:

    • 0 is for the entire world in one map tile
    • 14 is when buildings become visible on OpenStreetMap standard map rendering
Source:
Overrides:
See:

Zoom level

Equals to undefined for missing z search parameter. Numeric precision is the same as when setting GeoURL#u because Google documentation doesn't specify it.

Example values:

  • 0 is for the entire world in one map tile
  • 14 is when buildings become visible on OpenStreetMap standard map rendering
Type:
  • number | undefined

zoom :number|undefined

Description:
Source:
Overrides:

Zoom level

A longer name for GeoURL#z

Type:
  • number | undefined

Methods

set alt(value)

Description:
  • Set the altitude

Source:
See:
Examples
const url = new WGS84GeoURL("geo:13.4125,103.8667")
url.alt = 65
console.log(url.toString()) // outputs "geo:13.4125,103.8667,65"
const url = new WGS84GeoURL("geo:48.201,16.3695,183")
url.alt = undefined
console.log(url.toString()) // outputs "geo:48.201,16.3695"
Parameters:
Name Type Description
value number | undefined

altitude in meters or undefined

Throws:

if the value is neither a finite number nor undefined

Type
TypeError

set coordA(value)

Description:
  • Set the 1st coordinate

Source:
Overrides:
See:
Example
const url = new GeoURL("geo:60,30")
url.coordA = 61
console.log(url.toString()) // outputs "geo:61,30"
Parameters:
Name Type Description
value number
Throws:

if the value isn't a finite number

Type
TypeError

set coordB(value)

Description:
  • Set the 2st coordinate

Source:
Overrides:
See:
Example
const url = new GeoURL("geo:60,30")
url.coordB = 31
console.log(url.toString()) // outputs "geo:60,31"
Parameters:
Name Type Description
value number
Throws:

if the value isn't a finite number

Type
TypeError

set coordC(value)

Description:
  • Set the 3rd coordinate

Source:
Overrides:
See:
Examples
const url = new GeoURL("geo:60,30")
url.coordC = 5
console.log(url.toString()) // outputs "geo:60,30,5"
const url = new GeoURL("geo:60,30,5")
url.coordC = undefined
console.log(url.toString()) // outputs "geo:60,30"
Parameters:
Name Type Description
value number | undefined
Throws:

if the value is neither a finite number nor undefined

Type
TypeError

set coordinates(value)

Description:
  • Set coordinates to an array of numbers

Source:
Overrides:
See:
Example
const url = new WGS84GeoURL("geo:60,30;u=10")
url.coordinates = [61, 31, 5]
console.log(url.toString()) // outputs "geo:61,31,5;u=10"
Parameters:
Name Type Description
value Array.<number>

an array with two or three numbers

Throws:

if coordinates are out of allowed range or if GeoURL's setter throws

Type
TypeError

set coordinatesString(value)

Description:
  • Set coordinates to a string

Source:
Overrides:
See:
Example
const url = new WGS84GeoURL("geo:60,30;u=10")
url.coordinatesString = "61,31,5"
console.log(url.toString()) // outputs "geo:61,31,5;u=10"
url.coordinatesString = "0,181" // throws TypeError
Parameters:
Name Type Description
value string

a string of two or three comma-separated numbers, as they appear in the URL

Throws:

if coordinates are out of allowed range or if GeoURL's setter throws

Type
TypeError

set crs(value)

Description:
  • Set coordinate reference system

    The value is converted to lowercase on write.

    The crs geo parameter is deleted when setting to wgs84, ignoring the case.

Source:
Overrides:
See:
Parameters:
Name Type Description
value string

set hash(value)

Description:
  • Set hash property

Source:
Overrides:
See:
Parameters:
Name Type Description
value string

a string containing the URL fragment, with optional leading #

set lat(value)

Description:
  • Set the latitude

Source:
See:
Example
const url = new WGS84GeoURL("geo:13.4125,103.8667")
url.lat = 16.4321
console.log(url.toString()) // outputs "geo:16.4321,103.8667"
Parameters:
Name Type Description
value number

latitude in decimal degrees between -90 and 90

Throws:

if the value is out of range

Type
TypeError

set lon(value)

Description:
  • Set the longitude

Source:
See:
Example
const url = new WGS84GeoURL("geo:13.4125,103.8667")
url.lon = 101.1001
console.log(url.toString()) // outputs "geo:13.4125,101.1001"
Parameters:
Name Type Description
value number

longitude in decimal degrees between -180 and 180

Throws:

if the value is out of range

Type
TypeError

set search(value)

Description:
  • Set search/query string

Source:
Overrides:
See:
Parameters:
Name Type Description
value string

set u(value)

Description:
  • Set uncertainty

Source:
Overrides:
See:
Parameters:
Name Type Description
value number | undefined

new uncertainty value in meters or undefined to remove the uncertainty

set z(value)

Description:
  • Set zoom level

    Setting to undefined deletes the z search parameter.

Source:
Overrides:
See:
Parameters:
Name Type Description
value number | undefined

toJSON() → {string}

Description:
  • Serialize the URL, which is the same as converting it to a string

Source:
Overrides:
See:
  • MDN for toJSON() method
Returns:
Type
string

toString() → {string}

Description:
  • Convert the URL to a string

Source:
Overrides:
See:
  • MDN for toString() method
Returns:
Type
string

(static) canParse(url, baseopt) → {boolean}

Description:
  • Check if url is parsable as a valid WGS84 geo URI

Source:
See:
  • MDN for canParse() static method
Parameters:
Name Type Attributes Description
url string | URL | GeoURL

geo URI or relative reference

base string | URL | GeoURL <optional>

base geo URI

Returns:
Type
boolean

(static) parse(url, baseopt) → {WGS84GeoURL|null}

Description:
  • Create a WGS84GeoURL or return null on error

Source:
See:
  • MDN for parse() static method
Parameters:
Name Type Attributes Description
url string | URL | GeoURL

geo URI or relative reference

base string | URL | GeoURL <optional>

base geo URI

Returns:
Type
WGS84GeoURL | null