flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 503 forks source link

How to properly make use of the symbol Manager to allow icon clustering #1302

Closed vidriloco closed 1 year ago

vidriloco commented 1 year ago

Hello there,

I am having problems with making the SymbolManager to control the icon clustering amongst my map markers. I am initialising the SymbolManager as follows:

if(mapController?.symbolManager == null) {
  mapController?.symbolManager = SymbolManager(mapController!, iconAllowOverlap: true);
}

mapController?.symbolManager?.add(
  Symbol(name, symbolOptions, { "name": name })
);

However, Mapbox flutter in iOS (haven't tried in Android) keeps hiding the markers as I zoom out of the map.

Am I making a correct use of the SymbolManager?

scotch-formitable commented 1 year ago

I am having the same behaviour

BEibye commented 1 year ago

Hi, i was having the same issue, but it helped to also set the textAllowOverlap: true. But im still having issues clustering the icons, to ex. a circle showing the number of Symbols.

felix-ht commented 1 year ago

SymbolManager(iconAllowOverlap: true, iconIgnorePlacement: false) should do the trick.

Note that the symbol manger is created when the map has finished loading. So if you check for null you will never set a new SymbolManager. You can have as many SymbolManagers as you want btw - as along as you store them in a variable outside the controller.

If you want to use the ones from the controller you can just use:

controller.setIconAllowOverlap(your_setting)
controller.setTextAllowOverlap(your_setting) 
controller.setIconIgnorePlacement(your_setting) 
controller.setTextIgnorePlacement(your_setting) 

So there is no need to make a new one

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.