Leaflet R performance issues with large map

拜拜、爱过 提交于 2019-12-12 12:06:57

问题


I'm wondering if anyone else has experienced similar issues when plotting a large number of markers and polygons using leaflet package in R. This is what it normally should look like:

However, when I zoom in/out of the map, the polygons and markers are clearly out of place (or you can say the base map does not adjust properly). An example is included below:

I would not have this issue when I plotted a smaller area or few markers. I'm wondering if there is a way to improve the performance. Many thanks in advance for your help!

A sample of my code is included below:

map1 <- leaflet() %>%
    addProviderTiles("CartoDB.Positron") %>%

    addPolygons(data = data_merged, group="Default",
                fillColor = ~pal(minority_population), color = "orange", 
                fillOpacity = 0.7,weight = 1, smoothFactor = 0.2, popup = popup) %>%

    addMarkers(data = branches_temp, ~long, ~lat,
               popup=~name_branch, group="Branch Locations",
               icon=icons(iconUrl = "./data/bank_blue_marker.png",iconWidth=20, iconHeight=20))

来源:https://stackoverflow.com/questions/40063663/leaflet-r-performance-issues-with-large-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!