Stupid_Pink_Pony
Stupid_Pink_Pony

Reputation: 103

HERE maps for JavaScript API: How to get all noise points markers and clusters from the map?

I need to find all.requestMarkers which returns all cluster and noise point markers which intersect with the provided rectangular area.

Right now I can find all markers and cluster on Visual side of map

let viewBounds = map.getViewBounds(); //view bounds of map
let mapZoom = map.getZoom(); //map zoom
let arrayPoints = clusteredDataProvider.requestMarkers(viewBounds,mapZoom); //marker and cluster that we can see on map

But how I can get those markers and cluster from all map?

Upvotes: 0

Views: 980

Answers (1)

Tomas
Tomas

Reputation: 1887

You should define your theme within Provider's options. All is explained in Clustering custom theme example. The theme expects two callbacks, where you should create your map object. There you can for example add it to some global array for later usage:

let objects = [];

let CUSTOM_THEME = {
  getClusterPresentation: function(cluster) {
    let marker = new H.map.Marker(cluster.getPosition());
    objects.push(marker);
    return marker;
  }
  getNoisePresentation: function(noisePoint) {
    let marker = new H.map.Marker(noisePoint.getPosition());
    objects.push(marker);
    return marker;
  }
}

let clusteredDataProvider = new H.clustering.Provider(
  <YOUR_DATA_POINTS>,
  {
    theme: CUSTOM_THEME
  });

Here is simple jsfiddle example which counts all clusters and noisePoints.

Note: additionally in API version 3.1 you could simply call clusteredDataProvider.getRootGroup().getObjects()

Upvotes: 1

Related Questions