是否可以在r传单中添加小图像(缩略图)而不是标记/圆形标记?
我使用传单在r Shiny中创建地图,到目前为止效果很好。我有大量的空间点数据集,地图上显示的每个点都包含与该特定位置相关的图像。使用传单,我可以通过将鼠标悬停在反应性内容中来显示该图像
observeEvent(input$map1_marker_mouseover$id {})
或通过单击作为popupImage。
我现在想显示的是图像始终显示在屏幕上,而无需悬停或单击(从某些缩放级别开始)。>>
在下面找到一个最小的工作示例。
library(shiny)
library(leaflet)
library(mapview)
library(leafpop)
library(sf)
# testdata
loc = data.frame(x = jitter(rep(8.620000, 10), factor = 0.1),
y = jitter(rep(47.320000, 10), factor = 0.1))
loc = st_as_sf(loc, coords = c("x", "y"), crs = 4326)
image = 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Rlogo.png/274px-Rlogo.png'
# === UI ==========================
ui <- fluidPage(
div(class="outer", # use full space
# leaflet
leafletOutput("map1", width="100%", height="100%")),
# css-styling
tags$head(tags$style(HTML("
#map{
margin-top:18px;
margin-bottom:18px;
}
.outer {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
padding: 0;
margin-top:0;
}
")))
)
# === Server ==========================
server <- function(input, output, session) {
# === map
output$map1 <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addCircleMarkers(data=loc, radius = 5,
clusterOptions = markerClusterOptions(),
popup = paste0("<img src = ", image, ">"),
group="points")
})
}
# === RUN APP ==========================
shinyApp(ui, server)
是否有可能在r传单中添加小图像(缩略图)而不是标记/圆形标记?我使用传单在r Shiny中创建地图,到目前为止效果很好。我有一个很大的空间数据集...
请根据leaflet documentation尝试以下操作: