Leaflet Marketr Cluster 在 Shiny 中无法使用 Echarts4r
Leaflet Marketr Cluster Not working with Echarts4r In Shiny
不确定这是错误还是我做错了什么。当我在 shiny 中添加一个 echart 时,leaflet 中的标记簇消失了。当我删除 echart 时,地图工作正常。这与 htmlwidgets 有关系吗?代码如下。
library(leaflet)
library(dplyr)
library(shiny)
library(echarts4r)
# Create 3 map points -- 2 will be clustered
map_points <- bind_rows(c(location = 'A', lon = -122.4, lat = 37.8),
c(location = 'B', lon = -122.4, lat = 37.8),
c(location = 'C', lon = -118.2, lat = 34.0))
map_points$lon <- as.numeric(map_points$lon)
map_points$lat <- as.numeric(map_points$lat)
# Shiny
ui <- fluidPage(
leafletOutput("mymap"),
echarts4rOutput("myplot")
)
server <- function(input, output, session){
output$mymap <- renderLeaflet({
leaflet(map_points) %>%
addProviderTiles("OpenStreetMap.Mapnik") %>%
addCircleMarkers(lng = ~lon,
lat = ~lat,
group = "locations",
layerId = ~location,
# adding clusterOptions removes the group in observeEvent
clusterOptions = markerClusterOptions()
)
})
observeEvent(input$mymap_marker_click, {
print(input$mymap_marker_click)
})
output$myplot<-renderEcharts4r({
ex2<-map_points%>%
e_charts(x = lon)
ex2%>% e_scatter(lat)
})
}
shinyApp(ui = ui, server = server)
使用更新的存储库将解决问题。
remotes::install_github(“JohnCoene/echarts4r”)
不确定这是错误还是我做错了什么。当我在 shiny 中添加一个 echart 时,leaflet 中的标记簇消失了。当我删除 echart 时,地图工作正常。这与 htmlwidgets 有关系吗?代码如下。
library(leaflet)
library(dplyr)
library(shiny)
library(echarts4r)
# Create 3 map points -- 2 will be clustered
map_points <- bind_rows(c(location = 'A', lon = -122.4, lat = 37.8),
c(location = 'B', lon = -122.4, lat = 37.8),
c(location = 'C', lon = -118.2, lat = 34.0))
map_points$lon <- as.numeric(map_points$lon)
map_points$lat <- as.numeric(map_points$lat)
# Shiny
ui <- fluidPage(
leafletOutput("mymap"),
echarts4rOutput("myplot")
)
server <- function(input, output, session){
output$mymap <- renderLeaflet({
leaflet(map_points) %>%
addProviderTiles("OpenStreetMap.Mapnik") %>%
addCircleMarkers(lng = ~lon,
lat = ~lat,
group = "locations",
layerId = ~location,
# adding clusterOptions removes the group in observeEvent
clusterOptions = markerClusterOptions()
)
})
observeEvent(input$mymap_marker_click, {
print(input$mymap_marker_click)
})
output$myplot<-renderEcharts4r({
ex2<-map_points%>%
e_charts(x = lon)
ex2%>% e_scatter(lat)
})
}
shinyApp(ui = ui, server = server)
使用更新的存储库将解决问题。
remotes::install_github(“JohnCoene/echarts4r”)