私はRshinyで問題を解決する方法を知っている人がいるのだろうかと思っていました。要するに、リーフレットベースのマップマーカーでユーザーの現在のタブを更新するようにしています。理想的には、私のグループは、タブ内に収容された統計演習(この例では演習ではない演習)の間をナビゲートするために、マップを使用するようにします。updateTabsetPanelとリーフレットマーカーを統合しようとしていますR Shiny?
考えられるのは、ビルディングマーカーが特定のタブと関連しており、ユーザーが地図を見て、マーカーを確認してクリック数を確認し(ポップアップで)、下のタブが自動的に変更され、マーカー。
マップマーカーのマウスクリックが 'updateTabsetPanel'コマンドの入力として登録されるように実装しようとしましたが、レンガの壁に当たったようです。私はまた、正しいタブにユーザーをリダイレクトするためにポップアップ内にハイパーリンク/ URLを実装しようとしましたが、そこにも運がありませんでした。
以前は同じことをしようとしていた別の例を読んでいましたが、助けを求めている人はコードから抜粋していましたが、回答に従ってみましたが、私のコードのどこかに別の小さな問題があると私に思い出させてくれます。
私はShiny/Rに求めていることがはるかに複雑すぎると私に教えてくれるほど親切であるかもしれません。他の場所では時間がかかります。
ありがとうございます!あなたは、私がリンクをクリックしたときに、タブセットのパネルを更新するようにコードを変更したサーバーの一部についてtabPanel("Tab A", id = "A",
tabPanel("Tab A", value= "A",
にを変更する必要があるUIの部分では
**
library(leaflet)
library(shiny)
library(dplyr)
shinyServer(function(input, output, session) {
#I've tried hyperlinking to the tab with an action link/hyperlink
##that would appear in the popup
Popcontent1 <- paste(sep = "<br/>",
actionLink("?url=inTabset/Home", "Learn about A"),
"This would be the First Marker",
"and would update the tabs to a specific tab below")
Popcontent2 <- paste(sep = "<br/>",
actionLink("link_to_tabpanel_B", "Learn about B"),
"This one would also update to another tab")
output$London <- renderLeaflet({
London <- leaflet(options = leafletOptions(zoomControl = FALSE,
minZoom = 16, maxZoom = 16)) %>%
setView(lng = 0.12783, lat =51.50741, zoom = 16)%>%
addTiles(options = providerTileOptions(opacity = 0.45)) %>%
addCircleMarkers(lng=0.12783, lat=51.50741, radius = 13,
opacity = 0.5, color = "#008B45",
popup=Popcontent1)%>% #MarkerHome
addCircleMarkers(lng=0.12774, lat=51.50700, radius = 13,
color = "#48D1CC",popup=Popcontent2) #Marker2
PopTEST <- addCircleMarkers(London, lng=0.12800, lat=51.50650,
color = "#9400D3", popup=Popcontent1) #TestMarker
})
## Attempt at making the markers in the above map interactive.
## Ideally, clicking on the markers above would change the tabs,
## meaning users click on certain building marker and get relevant tab
observe({
event <- input$London_PopTEST_click
updateTabsetPanel(session, "inTabset", selected = event$A)
})
observeEvent(input$switchtab, {
event <- input$London_PopTEST_click
updateTabsetPanel(session, "inTabset", selected = event$A)
})
})
#########UI
shinyUI(fluidPage(
titlePanel("This is the Map"),
leafletOutput("London", width = "100%", height = 600),
br(),
tabsetPanel(id = "inTabset",
tabPanel(title = "Home", id = "Home",
h4("This is the Home Tab"),
br(),
mainPanel(),
fluidRow(
column(12,
p("This would be the introductory tab.")
))),
######################################## Tab A
tabPanel("Tab A", id = "A",
h4("This tab would be the next step"),
br(),
fluidRow(
column(12,
p("This tab would be brought up by the
marker/popup click in the map above.")
))))
))
**
こんにちは@SBista、ありがとうございました。私は両方の方法を試してみましたが、どちらも素晴らしい方法です。私は週末を過ごしましたが、あなたの助けを借りて最終的にはうまくいきました:)あなたが提案した最初の方法を選択して終了し、ユーザーがハイパーリンクを使用してさまざまなタブを変更させるようにします。将来の潜在的な読者の明快さのために、私は "link2_click \"、 "link3_click \"というように "link_click \"引数を変更し、これをobserveEvent(入力$ link2_click、{ updateTabsetPanel(session、 "inTabset "、" B ")for other marker – Wintermute