Ich muss eine Beschriftung von Polygon (mit dem Namen der Region) zeigen, wenn Sie die Maus über das Polygon bewegen. Allerdings kann das Polygon nicht anklickbar sein, da ich diese Eigenschaft für einen anderen Teil meines Codes habe. Ist das möglich?R Leaflet: Ist es möglich, eine Polygonbeschriftung anzuzeigen, wenn das Polygon nicht anklickbar ist?
Wenn dies nicht möglich ist, könnte eine andere Lösung darin bestehen, einen Namen auf das Polygon zu schreiben. Ich weiß auch nicht, wie ich das machen soll. :/
Hier ist, wie mein Code
library(shiny)
library(leaflet)
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("map", width = "100%", height = "100%")
)
# Load shapefiles
shp_Tajo <- readOGR(dsn = "./Data/ES", layer = "Aqueduct_river_basins_TEJO", verbose = FALSE)
server <- function(input, output, session){
output$map <- renderLeaflet({
# Arguments controlling the looks of the basin polygon
dopacity = 0.3
dsmoothFactor = 1
dfillOpacity = 0.5
vcolors = c("red")
leaflet() %>% addTiles() %>% addPolygons(data = shp_Tajo, stroke = F,
opacity = dopacity, smoothFactor = dsmoothFactor, color = vcolors[1], fillColor = vcolors[1],
fillOpacity = dfillOpacity, highlightOptions = highlightOptions(color = "white", weight = 2,
bringToFront = FALSE), options = pathOptions(clickable = FALSE), label = "Tajo",
labelOptions = labelOptions(noHide = T, clickable = T, textOnly = TRUE, opacity=0.5,textsize='15px'))
})
}
Die Form-Datei von http://riverbasins.wateractionhub.org/#find_lat_lng heruntergeladen werden kann, wo Sie wählen Spanien in der Dropdown-Menü so weit sieht.
Jede Hilfe würde sehr geschätzt werden!
bitte ein reproduzierbares Beispiel liefern – HubertL
@HubertL Ich habe jetzt ein reproduzierbares Beispiel aufgenommen. Vielen Dank für Ihren Kommentar. –
Das ist viel besser, aber Sie haben keinen Hinweis darauf, wie das Klickereignis in Ihrem Code – HubertL