Constructor
new GeoURL(url, baseopt)
- Description:
Create a GeoURL from a string or another URL object
Expected to be almost always invoked with one parameter because there's not much use of relative references in case of geo URIs. At best you can add a hash to a base geo URI using a relative reference, but hashes in geo URIs a probably not widely used.
- 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 |
Throws:
-
-
if the protocol is not
geo:
- Type
- TypeError
-
-
-
if contains less than two or more than three coordinates, or if some coordinates aren't numbers
- Type
- TypeError
-
Classes
Members
CRS :string
- Description:
Coordinate reference system
An alternative name for GeoURL#crs
- Source:
Coordinate reference system
An alternative name for GeoURL#crs
Type:
- string
coordA :number
- Description:
1st coordinate in an arbitrary CRS
- Source:
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:
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:
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:
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:
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:
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
- Source:
geo URI parameters object
Type:
hash :string
- Description:
Hash property containing the fragment identifier
- Source:
- See:
-
- MDN for hash property
Hash property containing the fragment identifier
Type:
- string
search :string
- Description:
Search/query string
- Source:
- See:
-
- MDN for search property
Search/query string
Type:
- string
(readonly) searchParams :URLSearchParams
- Description:
URLSearchParams object
- Source:
- 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:
- See:
-
- RFC 5870 for parameter 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.
Type:
- number | undefined
uncertainty :number|undefined
- Description:
Uncertainty in meters
A longer name for GeoURL#u
- Source:
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:
- See:
-
- Google Maps Intents for parameter 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
Type:
- number | undefined
zoom :number|undefined
- Description:
Zoom level
A longer name for GeoURL#z
- Source:
Zoom level
A longer name for GeoURL#z
Type:
- number | undefined
Methods
set coordA(value)
- Description:
Set the 1st coordinate
- Source:
- See:
-
- GeoURL#coordA for the corresponding getter
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:
- See:
-
- GeoURL#coordB for the corresponding getter
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:
- See:
-
- GeoURL#coordC for the corresponding getter
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:
- See:
-
- GeoURL#coordinates for the corresponding getter
Example
const url = new GeoURL("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 set to an array with unexpected number of elements, or if some values aren't finite numbers
- Type
- TypeError
set coordinatesString(value)
- Description:
Set coordinates to a string
- Source:
- See:
-
- GeoURL#coordinatesString for the corresponding getter
Example
const url = new GeoURL("geo:60,30;u=10")
url.coordinatesString = "61,31,5"
console.log(url.toString()) // outputs "geo:61,31,5;u=10"
Parameters:
Name | Type | Description |
---|---|---|
value |
string | a string of two or three comma-separated numbers, as they appear in the URL |
Throws:
-
if set to a string that has less than two or more than three comma-separated values, or if some values aren't finite numbers
- 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 towgs84
, ignoring the case.
- Source:
- See:
-
- GeoURL#crs for the corresponding getter
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
set hash(value)
- Description:
Set hash property
- Source:
- See:
-
- GeoURL#hash for the corresponding getter
Parameters:
Name | Type | Description |
---|---|---|
value |
string | a string containing the URL fragment, with optional leading |
set search(value)
- Description:
Set search/query string
- Source:
- See:
-
- GeoURL#search for the corresponding getter
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
set u(value)
- Description:
Set uncertainty
- Source:
- See:
-
- GeoURL#u for the corresponding getter
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:
- See:
-
- GeoURL#z for the corresponding getter
Parameters:
Name | Type | Description |
---|---|---|
value |
number | undefined |
toJSON() → {string}
- Description:
Serialize the URL, which is the same as converting it to a string
- Source:
- See:
-
- MDN for toJSON() method
Returns:
- Type
- string
toString() → {string}
- Description:
Convert the URL to a string
- Source:
- See:
-
- MDN for toString() method
Returns:
- Type
- string
(static) canParse(url, baseopt) → {boolean}
- Description:
Check if url is parsable as a valid 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) → {GeoURL|null}
- Description:
Create a GeoURL 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
- GeoURL | null