Create content using KML support

Creating content on top of a map is time consuming, therefore, most developers use standards to help them transfer content between platforms seamlessly. The most commonly used standard is KML which captures data in the XML format. For further information, see the KML page of the Open Geospatial Consortium.

The KML specification supports a variety of objects, such as Placemarks, images and Polygons. Many KML objects have counterparts in the HERE Maps API for JavaScript. To translate KML objects to map objects, use the data module in the Maps API (mapsjs-data.js).

The Reader class in the data module loads KML from a file and parses it. Further, the class has a utility method that creates a map layer, using the parsed KML data. The layer can be added directly to the map. All map objects receive regular map events (see Map Events) and can contain additional data, such as name and description (if such data is available in the KML document).

// Create reader object initializing it with a document:
var reader = new'path/to/kml/file.kml'),

// Parse the document:

// Get KML layer from the reader object and add it to the map:
layer = reader.getLayer();

// KML objects receive regular map events, so add an event listener to the 
// KML layer:
layer.getProvider().addEventListener('tap', function(ev) {
    // Log map object data. They contain name, description (if present in 
    // KML) and the KML node itself.

The HERE Maps API supports import of KML files and data sets compliant with versions 2.1 and 2.2 of the KML standard. There are only a small number of features that the Maps API does not as yet support, for example, 3D buildings. The imported data is interpreted in the best way possible and any unsupported features in the KML data structure are ignored.

The image below shows data imported from KML and rendered on a satellite map by the Maps API.

KML data rendered on a satellite map
Figure 1. KML data rendered on a satellite map

results matching ""

    No results matching ""