我是闪亮的传单和传单中的新手。我正试图绘制汽车的移动轨迹。
由于有一个名为animatedMaker的传单js的插件,有没有任何技术也可以实现这一点?我正在尝试使用leafletproxy和invidatelater。这是我的代码,根本不起作用。非常感谢您的帮助:
library(shiny)
library(leaflet)
server <- function(input, output,session) {
#read data from csv
latlon <- read.csv("tx_r1c_car_1.csv",header = TRUE)
i<-0
#filter time when user using the time slider
filteredData <- eventReactive(input$searchtime,{
latlon[latlon$time >= input$time[1] & latlon$time <= input$time[2],]
i = input$time[1]
})
#plot out limited marker every time
mark <- reactive({
invalidateLater(100,session)
i = i+0.1
filteredData[filteredData$time > i && filteredData$time <(i+0.2)]
})
observe({
invalidateLater(100,session)
leafletProxy("hist", data = mark()) %>%
clearMarkers() %>%
clearShapes() %>%
#addPolylines(~long,~lat,popup = ~as.character(speed))
addMarkers(~long,~lat,popup = ~as.character(speed))
})
#render leaflet
output$hist <- renderLeaflet({
leaflet() %>%
addTiles(options = providerTileOptions(noWrap = TRUE)) %>%
setView(lng = 150.8897244, lat = -34.4166942, zoom = 12)
})
}