Maps API for JavaScript Developer's Guide

H.data.kml.Reader

Class Summary

Extends: H.data.AbstractReader

The KML Reader is responsible for fetching and interpreting KML data. Reader creates H.map.Object that can be displayed on the map, from KML Features and geometries as described by OGC. Auxiliary data that accompanies geometries (such as name, description, kml node itself etc.) is binded to the map object and can be fetched with object's getData method (see H.map.Object#getData).

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

getLayer () : {H.map.layer.ObjectLayer}

Method returns H.map.layer.ObjectLayer that contains parsed data, and can be added directly to the map. It returns new instance of the class with every invocation. If data hasn't been parsed it will return H.map.layer.ObjectLayer that contains partial information, and reader will add new parsed objects to the layer's provider later on.

getParsedObjects () : {Array<H.map.Object>}

Method returns collection of currently parsed, and converted to H.map.Object data objects. Method returns only currently parsed objects if parsing is ongoing.

getUrl () : {(string | undefined)}

Returns URL of the current file, which is either in process of fetching/parsing or file that has been already parsed.

setUrl (url) : {H.data.AbstractReader}

Method sets reader's URL. Method resets current Reader's state to its initial values (clears data about last parsed objects, etc.), and throws InvalidState exception if Reader's state is not READY or ERROR.

getState () : {H.data.AbstractReader.State}

Returns the reader's processing state for possible states see H.data.AbstractReader.State

parse ()

Method launches parsing of the data file at the current url (see H.data.AbstractReader#setUrl or H.data.AbstractReader). Method uses XHR as a transport therefore same origin policy applies, or server should respond with proper CORS headers.

Events Summary

Table 2. Events
Events

statechange : {H.data.AbstractReader.Event}

Fired when the reader state changes, see H.data.AbstractReader#getState

Class Description

The KML Reader is responsible for fetching and interpreting KML data. Reader creates H.map.Object that can be displayed on the map, from KML Features and geometries as described by OGC. Auxiliary data that accompanies geometries (such as name, description, kml node itself etc.) is binded to the map object and can be fetched with object's getData method (see H.map.Object#getData).

Note that you can load KML file even from a different domain, if that domain supports Cross-Origin Resource Sharing (see http://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS).

Example

var reader = new H.data.kml.Reader('/path/to/kml/file.kml');
reader.parse();
//assuming that map already exists
map.addLayer(reader.getLayer());

Constructor Details

H.data.kml.Reader(url)

Parameters:
 
url:
{string}
 

Method Details

getLayer () : {H.map.layer.ObjectLayer}

Method returns H.map.layer.ObjectLayer that contains parsed data, and can be added directly to the map. It returns new instance of the class with every invocation. If data hasn't been parsed it will return H.map.layer.ObjectLayer that contains partial information, and reader will add new parsed objects to the layer's provider later on.

Returns:
 
{H.map.layer.ObjectLayer}

getParsedObjects () : {Array<H.map.Object>}

Method returns collection of currently parsed, and converted to H.map.Object data objects. Method returns only currently parsed objects if parsing is ongoing.

Returns:
 
{Array<H.map.Object>}

getUrl () : {(string | undefined)}

Returns URL of the current file, which is either in process of fetching/parsing or file that has been already parsed.

Returns:
 
{(string | undefined)}
url

setUrl (url) : {H.data.AbstractReader}

Method sets reader's URL. Method resets current Reader's state to its initial values (clears data about last parsed objects, etc.), and throws InvalidState exception if Reader's state is not READY or ERROR.

Parameters:
 
url:
{string}
 
The new URL
Returns:
 
{H.data.AbstractReader}

getState () : {H.data.AbstractReader.State}

Returns the reader's processing state for possible states see H.data.AbstractReader.State

parse ()

Method launches parsing of the data file at the current url (see H.data.AbstractReader#setUrl or H.data.AbstractReader). Method uses XHR as a transport therefore same origin policy applies, or server should respond with proper CORS headers.

Event Details

statechange: {H.data.AbstractReader.Event}

Fired when the reader state changes, see H.data.AbstractReader#getState

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.