Maps API for JavaScript Developer's Guide

KML Support

Because creating content on top of a map is time consuming, most developers look to standards to help them transfer content between platforms seamlessly. They typically use KML, which captures data in XML. For further information, please visit 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 the data are present in the KML document).

<script type="text/javascript" charset="utf-8">
  // Create reader object initializing it with a document:
  var reader = new H.data.kml.Reader('path/to/kml/file.kml'),
  
  // Parse the document:
  reader.parse();

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

  // 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.
    console.log(ev.target.getData());
  });
</script>

The HERE Maps API supports the 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 are 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.

Figure 1. KML data rendered on a satellite map

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.