cweiske
cweiske

Reputation: 31068

Here Maps: Currently visible markers

I have a HERE maps based javascript map on a website with a list of markers. When the user zooms and pans the map, the mapviewchangeend event is triggered.

In that event, how can I find out which markers are currently visible?

The H.Maps object has a getObjectsWithin method, but that one needs a polygon - which I don't know how to obtain.

Upvotes: 1

Views: 567

Answers (1)

Tomas
Tomas

Reputation: 1887

As polygon you should use the bounds from ViewModel's getLookAtData method:

map.addEventListener('mapviewchangeend', (e) => {
  let bounds = map.getViewModel().getLookAtData().bounds;
  map.getObjectsWithin(bounds, (objects) => {
    console.log(objects);
  })
})

For more information check the H.map.ViewModel.getObjectsWithin documentation.

Upvotes: 2

Related Questions