ramnathv / rMaps

Interactive Maps from R
http://rmaps.github.io
389 stars 194 forks source link

how to dynamically set waypoints #110

Closed shahan92 closed 8 years ago

shahan92 commented 8 years ago

i wanted to set more than two waypoints dynamically with latlong from a csv file. "test<-read.table("data/flows.csv",header=TRUE, sep = ",")" this csv file has two latlongs. 1st is starting and 2nd is ending

i am using leaflet routing machine and setting a way point like output$routeMap <- renderUI({

        mywaypoints = list(c(64.200841, -149.493673), c(56.130366, -73.99302))
        tags$body(tags$script(HTML(sprintf(
            "var mywaypoints = %s  
            L.Routing.control({
            waypoints: [
                L.latLng.apply(null, mywaypoints[0]),
                L.latLng.apply(null, mywaypoints[1])
            ] }).addTo(map)", RJSONIO::toJSON(mywaypoints)
        ))))
    })

how to set dynamic values in mywaypoints variable, if i want to show more than two routes on a map please help. thank you