R - Leaflet Limitations - How many markers does a leaflet map support?

前端 未结 2 1842
無奈伤痛
無奈伤痛 2021-01-28 05:24

Data

I have a dataframe which contains 35,000 lat/lon locations. The locations have been plotted onto an interactive leaflet map.

The S

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-28 05:43

    There are a couple options I can think that might help. The best would probably be to make clusters (see Marker Clusters):

    addMarkers(..., clusterOptions = markerClusterOptions())
    

    This prevents all 35 000 points from rendering at once which speeds up the loading time.

    addCircles() and addCircleMarkers() seem to load quicker than addMarkers() as well if they're okay for your purposes although they're still slow with 35 000 points.

    You could then do:

    addCircleMarkers(..., clusterOptions = markerClusterOptions())
    

    which should load even faster.

    Update

    Use leaflet.glify (devtools::install_github("tim-salabim/leaflet.glify"))

    [Now leafgl (devtools::install_github("r-spatial/leafgl")) - see comment below.]

    See leaflet.glify [Now leafgl - see comment below.]

提交回复
热议问题