Fleet Telematics Advanced Data Sets

Showing Fleet Telematics Advanced Data Sets Layer on the Map

HERE Maps API for JavaScript provides an easy way to overlay Fleet Telematics Advanced Data Sets thematic layers on the map. The Fleet Telematics Advanced Data Sets layers can be used to enrich the map experience by providing additional data: postcodes, census data, road classes, junction views etc. More information about available thematic layers is provided by the layers Fleet Telematics Advanced Data Sets REST API endpoint.

The code example below shows a simple use case involving the Fleet Telematics Advanced Data Sets thematic layer in which the map user can tap on the postcode data polygon centroid markers to view more information. When executed, the code performs the following operations:

  1. Gets an instance of the Platform Data Extension service.
  2. Creates Fleet Telematics Advanced Data Sets provider with the 'PSTLCB_GEN' thematic layer, and polyline rendering types.
/**
 * Assuming that "map" and "platform" are already initialized
 */
 // Create default map layers:
var service = platform.getPlatformDataService();

style = new mapsjs.map.SpatialStyle();
// create tile provider and layer that displays postcode boundaries
var boundariesProvider = new mapsjs.service.extension.platformData.TileProvider(service,
{
  layer: 'PSTLCB_GEN', level: 12
}, {
  resultType: mapsjs.service.extension.platformData.TileProvider.ResultType.POLYLINE,
  styleCallback: function(data) {return style}
});
var boundaries = new mapsjs.map.layer.TileLayer(boundariesProvider);
map.addLayer(boundaries);

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

  1. Creating additional layer with 'PSTLCB_MP' thematic layer, that contains postcode area centroids, and setting its resultType to H.map.Marker.
  2. Registering a tap event listener with the tile provider responsible for the 'PSTLCB_MP' layer.
// create tile provider and layer that displays postcode area centroids
var centroidsProvider = new mapsjs.service.extension.platformData.TileProvider(service,
{
  layer: 'PSTLCB_MP', level: 12
}, {
  resultType: mapsjs.service.extension.platformData.TileProvider.ResultType.MARKER
});
var centroids = new mapsjs.map.layer.MarkerTileLayer(centroidsProvider);
map.addLayer(centroids);

// add events listener, that outputs data provided by the Platform Data Extenstion and
// associated with the H.map.Marker
centroidsProvider.addEventListener('tap', function(ev) {
  var markerData = ev.target.getData();
  console.log(markerData.getCell('POSTAL_CODE'), markerData.getCell('ISO_COUNTRY_CODE'))
});

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

The image below shows the observable effects of this code on the map.

Map with postcode areas and centroids rendered from the Fleet Telematics Advanced Data Sets
Figure 1. Map with postcode areas and centroids rendered from the Fleet Telematics Advanced Data Sets

Showing and Matching Fleet Telematics Advanced Data Sets Search Results

Another option to display Fleet Telematics Advanced Data Sets data with HERE Maps API for JavaScript is to use the SearchRequest class. This option should be used when existing data (geocoding, routing etc. results) should be annotated with the data provided by Fleet Telematics Advanced Data Sets REST API thematic layers. The SearchRequest data event enables flexible way to perform search for data within the bounding box and to match the results with existing data by various attributes, such as link ids, names etc.

The code example below shows how to use SearchRequest functionality to existing data with the Fleet Telematics Advanced Data Sets. When executed, the code performs the following operations:

  1. Creates a SearchRequest for the 'EVCHARGING_POI' thematic layer.
  2. Adds an event listener to the 'data' event of the SearchRequest.
  3. The event listener processes the data available in the event argument and matches it against the available set of link ids. If there is a match, the code adds a map object to the map.
/**
 * Assuming that "map" and "platform" are already initialized, and there is
 * a processed routing response that includes a polyline and an array of 'linkids'
 * that represent legs of the route.
 */
var service = platform.getPlatformDataService();

// search the charging stations by the bounding box
service.searchByBoundingBox(['EVCHARGING_POI'], ['POI_ID'], polyline.getBoundingBox(), 
  (rows) => {
    rows.forEach((row) => {
      map.addObject(
        new mapsjs.map.Marker(
          // read marker position from the data row
          row.getCell('WKT').getGeometries()[0]
        )
      );
    })
  }, (e) => {console.log(e)});

results matching ""

    No results matching ""