mikewilliamson
mikewilliamson

Reputation: 24783

How to control what markers are displayed by mapbox-gl-js

I am loading a bunch of geojson points. I can see that I am loading about 40 points but which ones get displayed on my map seems random and somehow connected to the zoom level. Below you can see that only 2 points of ~40 are displayed.

markers from geojson

What criteria does mapbox-gl-js use to decide what to display?

Is there a way to control what points are being displayed? (All of them? Some based on an attribute?)

Upvotes: 2

Views: 1105

Answers (1)

Lucas Wojciechowski
Lucas Wojciechowski

Reputation: 3782

This is likely occurring because you are using the default text-allow-overlap value of false. The text-allow-overlap documentation reads

If true, the text will be visible even if it collides with other previously drawn symbols.

Because your symbols overlap each other, some are hidden. You can disable this behavior by setting text-allow-overlap to true.

You might find marker clustering to be useful.

Upvotes: 1

Related Questions