Maps API for JavaScript Developer's Guide

H.service.Url

Class Summary

This class represents a URL giving access to the individual parts that make up a URL,such as the scheme, host/domain, path, etc. Use the static parse method to populate a new URL object from a URL string. Be aware that URLs with user and password like "ftp://user:password@foo.bar/" are not supported!

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

static parse (url, opt_baseURL) : {H.service.Url}

This function parses a URL string and returns a H.service.Url object. The URL string must contain at least a scheme and a host.

clone () : {H.service.Url}

Clones this URL object. Optionally, mutations can be passed to this function to modify properties of the cloned object. Note that URL parameters are not replaced but merged with the parameters of this instance.

setScheme (scheme) : {H.service.Url}

This function sets the scheme of this URL object.

getScheme () : {string}

This function returns the scheme of this Url object.

setHost (host) : {H.service.Url}

This function sets the host of this URL object.

getHost () : {string}

This function returns the host name of this Url object.

setPath (path) : {H.service.Url}

This function sets the path of this URL object.

getPath () : {(string | undefined)}

This function returns the path part of this Url object.

setQuery (params) : {H.service.Url}

This function sets the specified parameters for this URL object. Keys in this object, which are associated with undefined values will be treated as query string parameters with no value.

hasQuery () : {boolean}

This function returns a boolean value indicating whether there are any query string parameter associated with this URL.

getQuery () : {Object}

This function returns the query object of this Url object.

setAnchor (anchor) : {H.service.Url}

This function sets the anchor of this URL object.

getAnchor () : {(string | undefined)}

This function returns the anchor of this Url object.

mergeQuery (other) : {H.service.Url}

This function merges the provided parameters into this URL's existing parameters. Key-value pairs which are defined in the argument and this URL's parameters will be overwritten. Key-value pairs which are defined in the argument and are not defined in this URL's parameters will be added. Prototype properties and function properties will not be merged.

addSubDomain (subDomain) : {H.service.Url}

This function adds a sub-domain to the host of this URL object.

addSubPath (subPath) : {H.service.Url}

This function adds a sub-path to this URL's path

toString () : {string}

This function formats this URL object to a full URL string.

Class Description

This class represents a URL giving access to the individual parts that make up a URL,such as the scheme, host/domain, path, etc. Use the static parse method to populate a new URL object from a URL string. Be aware that URLs with user and password like "ftp://user:password@foo.bar/" are not supported!

Constructor Details

H.service.Url(scheme, host, opt_path, opt_params, opt_port, opt_anchor)

Parameters:
 
scheme:
{string}
 
the URL scheme (e.g. "http" or "https" or "mailto")
host:
{string}
 
the host (or domain) part of the URL
opt_path:
{string=} [optional]
 
the path following the host pointing to a resource
opt_params:
{Object=} [optional]
 
the query string parameters of this URL
opt_port:
{number=} [optional]
 
The port of the host on which the host listens. If a string is passed it must be convertible to an integer.
opt_anchor:
{string=} [optional]
 
an optional anchor part of the URL (usually preceded by '#');

Method Details

static parse (url, opt_baseURL) : {H.service.Url}

This function parses a URL string and returns a H.service.Url object. The URL string must contain at least a scheme and a host.

Parameters:
 
url:
{string}
 
The URL string to parse.
opt_baseURL:
{string=} [optional]
 
The base URL to use to resolve relative URLs. If ommited the base URL of the document which loaded the API is taken.
Returns:
 
{H.service.Url}
the parsed URL object

clone () : {H.service.Url}

Clones this URL object. Optionally, mutations can be passed to this function to modify properties of the cloned object. Note that URL parameters are not replaced but merged with the parameters of this instance.

Returns:
 
{H.service.Url}
the clone of the URL object

setScheme (scheme) : {H.service.Url}

This function sets the scheme of this URL object.

Parameters:
 
scheme:
{string}
 
the new scheme
Returns:
 
{H.service.Url}
this URL object

getScheme () : {string}

This function returns the scheme of this Url object.

Returns:
 
{string}
the scheme (for example 'http')

setHost (host) : {H.service.Url}

This function sets the host of this URL object.

Parameters:
 
host:
{string}
 
the new host
Returns:
 
{H.service.Url}
this URL object

getHost () : {string}

This function returns the host name of this Url object.

Returns:
 
{string}
the host (for example 'api.here.com')

setPath (path) : {H.service.Url}

This function sets the path of this URL object.

Parameters:
 
path:
{(string | undefined)}
 
the new path or a boolean to clear the path
Returns:
 
{H.service.Url}
this URL object

getPath () : {(string | undefined)}

This function returns the path part of this Url object.

Returns:
 
{(string | undefined)}
the path (for example 'myresources/resource.html')

setQuery (params) : {H.service.Url}

This function sets the specified parameters for this URL object. Keys in this object, which are associated with undefined values will be treated as query string parameters with no value.

Parameters:
 
params:
{(Object | undefined)}
 
a hash of query string parameters specifying the parameters to be set.or a boolean to clear the parameters.
Returns:
 
{H.service.Url}
this URL object

hasQuery () : {boolean}

This function returns a boolean value indicating whether there are any query string parameter associated with this URL.

Returns:
 
{boolean}
true if there are parameters, false if none are present

getQuery () : {Object}

This function returns the query object of this Url object.

Returns:
 
{Object}
the query object

setAnchor (anchor) : {H.service.Url}

This function sets the anchor of this URL object.

Parameters:
 
anchor:
{(string | boolean | undefined)}
 
the new anchor or undefined to clear the anchor
Returns:
 
{H.service.Url}
this URL object

getAnchor () : {(string | undefined)}

This function returns the anchor of this Url object.

Returns:
 
{(string | undefined)}
the anchor

mergeQuery (other) : {H.service.Url}

This function merges the provided parameters into this URL's existing parameters. Key-value pairs which are defined in the argument and this URL's parameters will be overwritten. Key-value pairs which are defined in the argument and are not defined in this URL's parameters will be added. Prototype properties and function properties will not be merged.

Example

var url = new H.service.Url('http', 'api.here.com');
url.setQuery({ 'foo': 'bar' });
url.mergeQuery({ 'foo': 'baz', 'bar': 'foo' });

var newQuery = url.getQuery();
newQuery['foo'] === 'bar' // false
newQuery['foo'] === 'baz' // true
newQuery['bar'] === 'foo' // true
Parameters:
 
other:
{Object}
 
the parmeters to be merged into this URL's query string parameters
Returns:
 
{H.service.Url}
this URL object

addSubDomain (subDomain) : {H.service.Url}

This function adds a sub-domain to the host of this URL object.

Parameters:
 
subDomain:
{string}
 
the sub domain (non-empty string) to be added
Returns:
 
{H.service.Url}
this URL object

addSubPath (subPath) : {H.service.Url}

This function adds a sub-path to this URL's path

Parameters:
 
subPath:
{string}
 
the path to be added
Returns:
 
{H.service.Url}
this URL object

toString () : {string}

This function formats this URL object to a full URL string.

Returns:
 
{string}
the URL's string representation

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.