Frank
Frank

Reputation: 775

Using ClusterProvider in Nokia/Here Maps Javascript API, invalid cluster numbers

I'm trying to add the cluster to my application and so far, everything works.

However, the number of items in clusters seems to be invalid depending on zoom levels. For example, I add 3 marker in a range of about 30 feets. If I'm zoomed in all the way, I see all 3 markers. If I zoom out just a few steps, I can see 2 markers plus a cluster indicating 3 items.

I attached a picture, top part of the pictures shows the problem. If I zoom in a bit, it shows the bottom part of the picture. If I zoom out more, it shows a cluster of 3.

Thanks

Top portion of the image shows the problem, bottom shows a little more zoomed in version showing all the markers

Upvotes: 1

Views: 605

Answers (1)

Jason Fox
Jason Fox

Reputation: 5290

Try fiddling around with the ClusterProvider.Options. Obviously all clustering algorithms are an approximation of the actual data set, and maybe the particular distribution of points you have just doesn't look good at a high zoom using the defaults.

Here are three suggestions to try:

  • Lower the eps value to get a finer grid.
  • Set max and min or minPts to avoid clustering at lower levels.
  • Set the strategy to STRATEGY_GRID_BASED rather than use the density default.

e.g. something like this:

function clusterDataPoints(data){
    clusterProvider = new nokia.maps.clustering.ClusterProvider(map, {
        eps: 5,
        minPts: 5,
        min: 18,
        strategy: nokia.maps.clustering.ClusterProvider.STRATEGY_GRID_BASED,
        dataPoints: data
    });
    clusterProvider.cluster();

}

And keep altering the parameters until it "looks right"

Upvotes: 3

Related Questions