リーフレットの地図表示でシャインダッシュボードを構築していて、ユーザーの入力に基づいてポップアップテキストを表示するのが難しいです。ここでは、コード(私はまだその上で作業を開始していないとして、「出力$バー」の部分を無視することができます)今のところです:私がしようとしてる何リーフレットのポップアップがRの入力で更新されない
## app.R ##
library(shinydashboard)
library(shiny)
library(leaflet)
library(ggplot2)
refs <- read.csv('./BSAProjects/HurricaneModel/Data/monthlyrefinerymeanprod.csv', stringsAsFactors = FALSE)
hurs <- read.csv('./BSAProjects/HurricaneModel/Data/hurrdates.csv', stringsAsFactors = FALSE)
huricon <- makeIcon('http://www.youngsvillepolice.com/wp-content/uploads/2015/11/action-icon-HURRICANE.png',
iconWidth = 70,
iconHeight = 70)
ui <- dashboardPage(
dashboardHeader(title = 'Hurricane Model'),
dashboardSidebar(disable = TRUE),
dashboardBody(
fluidRow(
box(leafletOutput('leaflet'),
width = '100%')),
fluidRow(
box(selectInput('menu','Hurricane', choices = hurs$hurricane)),
box(plotOutput('bar', 'Production Levels'))
)
)
)
server <- function(input, output) {
colors <- colorFactor(rainbow(length(refs$SPRRegion)), refs$SPRRegion)
output$leaflet <- renderLeaflet({
map <- leaflet() %>%
addTiles(urlTemplate = 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}') %>%
addCircleMarkers(~Longitude,
~Latitude,
popup = paste('<b>EIAID:</b>', refs$EIAID, '<br>',
'<b>SPR Refinery Group:</b>', refs$Refinery.Group, '<br>',
'<b>Refinery:</b>', refs$SprRespondentName, '<br>',
'<b>Capacity:</b>', refs$Capacity, 'MBbl/day'),
clusterOptions = markerClusterOptions(),
color = ~colors(SPRRegion),
data = refs) %>%
addMarkers(~longitude,
~latitude,
icon = huricon,
popup = paste('<b>Hurricane:</b>', hurs$hurricane,'<br>',
'<b>Date:</b>', hurs$date,'<br>',
'<b>HSI:</b>', hurs$hsi),
data = hurs[hurs$hurricane == input$menu,])
})
output$bar <- renderPlot({
bar <- ggplot(hurs, aes())
})
}
shinyApp(ui, server)
は、ユーザーが選択できるようにすることですUIオブジェクト内で「selectInput」で作成されたドロップダウンメニューによってハリケーンが表示されます。それは、その後で、私が持っている情報を含むポップアップ「addMarkers(ポップアップ= ...)」
私が正常に基づいリーフレットマップにマーカーを配置するための機能を得ることができるとリーフレットマップにマーカーを追加しますポップアップテキストは常に「hurs」データファイルの最後の行に表示されるのと同じハリケーンです。私は行削除する場合:
data = hurs[hurs$hurricane == input$menu,]
をしているすべてのハリケーンは、その後、私は何の問題を持っていない代わりに
data = hurs
をプロットしました。私は "addCircleMarkers"オブジェクト内のラベルの更新に問題はないので、これはデータセットがドロップダウンメニューに基づいてどのようにフィルタリングされているかと関係があると思われます。
アイデア?