leafgl
leafgl copied to clipboard
_glify_clicks does not support linestrings
Hello,
I've been trying to register glify_clicks within a shiny app. It works just fine for polygon layers added with addGlPolygons() but does not register the click for linestrings added with addGlPolylines(). I've created a short reprex below.
library(shiny)
library(sf)
library(osmdata)
library(leaflet)
library(leafgl)
highways_castellon <- opq("Castellon de la Plana, ES")%>%
add_osm_feature(key = "highway")%>%
osmdata_sf()%>%
head(1000)
lines_dat<-highways_castellon$osm_lines
polygons_dat<-highways_castellon$osm_polygons
# Define UI
ui <- fluidPage(
leafglOutput("map_line", height='40vh')
,br()
,leafglOutput("map_poly", height='40vh')
)
# Define server logic
server <- function(input, output) {
output$map_line <- renderLeaflet({
map_line <- leaflet(
options=leafletOptions(zoomSnap=0.1)
)%>%
addProviderTiles("CartoDB.DarkMatter",group="Dark")%>%
addGlPolylines(
data=lines_dat
,color='blue'
,src=TRUE
,weight=1
)
})
observeEvent(input$map_line_glify_click,{
print("Linestring: ")
print(input$map_line_glify_click)
})
output$map_poly <- renderLeaflet({
map_poly <- leaflet(
options=leafletOptions(zoomSnap=0.1)
)%>%
addProviderTiles("CartoDB.DarkMatter",group="Dark")%>%
addGlPolygons(
data=polygons_dat
,fillColor='white'
,fillOpacity=0
,color='grey'
,stroke=1
,group="net_framework"
)
})
observeEvent(input$map_poly_glify_click,{
print("Polygon: ")
print(input$map_poly_glify_click)
})
}
# Run the application
shinyApp(ui = ui, server = server)
I think its because of src=TRUE. (The **Src functions are still missing the mousehandler etc).
Can you try to set it to FALSE and test again?
Apologies for the long delay in responding. I tested with src=FALSE and no longer have the noted issue. Appreciate your help getting things figured out.