alex3165 / react-mapbox-gl

A React binding of mapbox-gl-js
http://alex3165.github.io/react-mapbox-gl/
MIT License
1.91k stars 534 forks source link

Disable automatic feature decluttering #561

Closed hughlomas closed 6 years ago

hughlomas commented 6 years ago

I have a Map with Layer and Feature to which I have added hundreds of 'markers' (as ReactMapboxGl.Feature).

Currently the library hides many of the markers that are displayed, it appears to automatically declutter them so that there are no overlaps.

I don't want this behavior, I want to see all of the markers at once.

How do I disable this decluttering?

decluttering gif

<Map
  id="agent-map"
  style="mapbox://styles/mapbox/streets-v8"
>
  <Layer
    type="symbol"
    id="marker"
    images={images}
    layout={{ 'icon-image': 'agentMarker' }}
  >
      {agents.map( agent  => {
        return (<Feature
          coordinates={[agent.lng, agent.lat]}
          key={agent.id} 
        />);
      })}
  </Layer>
</Map>
hughlomas commented 6 years ago

Found the answer for anyone else looking:

adding 'icon-allow-overlap': true to the Layer layout property made it work as expected.

<Layer
            type="symbol"
            id="marker"
            images={images}
            layout={{
              'icon-image': 'agentMarker',
              'icon-allow-overlap': true
            }}
          >