PaulLeCam / react-leaflet

React components for Leaflet maps
https://react-leaflet.js.org
Other
5.13k stars 884 forks source link

Issue with large dataset #158

Closed patrickml closed 8 years ago

patrickml commented 8 years ago

Please make sure to check the following boxes before submitting an issue. Thanks!

Load 10k markers onto a map of the united states

Actual behavior

Browser freezing and crashing

Steps to reproduce

Load a 10k data set

const MAP = ({ suppliers }) => (
  <Map center={[37.09, -95.71]} zoom={4}>
    <TileLayer
      url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
      attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    />
    {
      suppliers.map((supplier, index) => (
        <Marker position={[supplier.LATITUDE, supplier.LONGITUDE]} key={index} />
      ))
    }
  </Map>
);

Here is a fiddle https://jsfiddle.net/68442vy5/3/ be warned it will crash your tab on chrome

PaulLeCam commented 8 years ago

Hi, Sorry but it's not something I'm going to investigate this, as needing 10k markers to be visible is likely to be a very rare edge case. Future changes notably by using context instead of props as suggested in this issue would likely improve the performance of this lib, but no matter what it is an abstraction on top of Leaflet and therefore comes as a certain cost.

Regarding your use case, do you absolutely need to have all these markers visible rather than reducing them to the visible bounds?

kujon commented 8 years ago

👍 10k may be an edge case, but the performance starts to suffer around 500 markers already. Go over 1/2k and the map is barely usable.

patrickml commented 8 years ago

@PaulLeCam instead od loading markers I ended up creating polygons to over an area -- I really just needed to map the data to see overlapping areas. Marker/Popups were really just nice to view the data.

Thank you for your time. @kujon Thank you for letting me know about the 500 limit before performance tanking. I will keep that in mind for future projects.