Disable popups for clustered points

2019-08-09 15:41发布

问题:

i'm running a map-based service with a lot (few thousands) of marked places. I decided to use OpenLayers with cluster support.

Each point has it's popup with some basic informations about it. The thing is that when a big amount of points are clustered, the popup for those i.e. 50 elements is really huge, bigger than the OpenLayers div and as you can imagine - it looks terrible.

Is there any possibility to disable popups for clustered points?

Thanks in advance

回答1:

In OpenLayers example, display function is called every time feature or cluster is selected. .I guess you do something similar:

function display(event) {
  //Show popup here      
}

event.feature has property called cluster which either contains one feature if it's the feature itself or an array of features if it's a clustered feature. I suggest that you check length of an array and show popup only when you have one feature in it.

That's the best suggestion I can make without seeing your code :)