Adding many polylines to R leaflets

Is there a way to add all my polylines at once. Do it below, very slowly ...

At the moment I am doing it through a for loop like this:

leafletProxy("mainMap") %>% 
          addPolylines(lng = currentGeoData[i,c("CustLon","SerCenterLon")], 
                       lat = currentGeoData[i,c("CustLat","SerCenterLat")],
                       color = "red")

      

so every time my variable lng

is a vector of length 2 and my variable is the lat

same.

+3


source to share


1 answer


As long as you are looking at the entire column, you do not need to index with i

:



leafletProxy("mainMap") %>% 
        addPolylines(lng = currentGeoData[c("CustLon","SerCenterLon")], 
                   lat = currentGeoData[c("CustLat","SerCenterLat")],
                   color = "red")

      

0


source







All Articles