Fleet Telematics Custom Locations

Showing Fleet Telematics Custom Locations Layer on the Map

HERE Maps API for JavaScript provides an easy way to overlay Fleet Telematics Custom Locations layers on the map. The Fleet Telematics Custom Locations layers are used to bring user provided geospatial data to the map. More information about managing layers could be found in Fleet Telematics Custom Locations REST API documentation.

The code example below shows a simple use case involving the Fleet Telematics Custom Locations layer in which the map user can tap on the building footprint polygons to view information about the area of the building. Layer's data in the example is assumed to be uploaded to the service via REST API or administration panel. The layer_id is determined at upload time. When executed, the code performs the following operations:

  1. Gets an instance of the Custom Location Extension service.
  2. Creates Custom Location Extension provider with the 'SEATTLE' layer, and a polygon rendering types.
  3. Registers a tap event listener with the tile provider responsible for the 'SEATTLE' layer.
/**
 * Assuming that "map" and "platform" are already initialized, and
 * CLE data layer was uploaded to the service.
 */
 // Create default map layers:
var service = platform.getCustomLocationService();

// create tile provider and layer that displays CLE layer
var provider = new H.service.extension.customLocation.TileProvider(service, {
  layerId: 'SEATTLE_14'
}, {
  resultType: H.service.extension.TileProvider.ResultType.POLYGON,
  min: 15
});

var layer = new H.map.layer.TileLayer(provider);
map.addLayer(layer);

map.addEventListener('tap', function(ev) {
  var row;
  if (ev.target !== map) {
    row = ev.target.getData();
    console.log('SHAPE_AREA: ', row.getCell('SHAPE_AREA'));
  }
});

The example above uses the H.map.SpatialStyle with the default settings, however, the API allows you to change the style callback to take custom data attributes into account. The code below extends the initial steps from the previous examples by:

The listener is a callback function to be invoked when the map user taps on a map (spatial) object, for example a polygon. It retrieves the object from the event passed to it and outputs information associated with the object to the console.

results matching ""

    No results matching ""