0
votes

I'm building a mapbox solution to show some entities' travel, like rented cars. I've one source of Geojson data, each geojson feature has the car ID as property, and a boolean to tell if this feature is the current one (current car location) or not.

For each car id I create two layers : one for the path, one for the current position (it's a circle). It's for this one I've a problem. When all cars are back home (at the same place), I only see the top one layer because all points are stacked.

In Mapbox documentation we can see that styling is configured on the layer level. How can I show a special style when two or more layers have something to print at same location?

1

1 Answers

2
votes

There isn't a perfect solution for this one.

  • If you are using a GeoJSON source: You can use clusterisation directly from Mapbox. It will show you how many elements are at the same spot.

  • If you are using a any source: You can use the spiderfy library. You can then link it to different events. Note that you can use this with clusters too.

You can also compute new features that sum the number of cars at the same spot and change the styling on the color depending this new property.

Note that any event always has all the stacked features that were concerned by this event.