Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lfx-search-prod.js to allow searching of circle makers #218

Closed
wants to merge 1 commit into from

Conversation

wyuill
Copy link

@wyuill wyuill commented May 29, 2024

allow searching of circle markers as per #143 by removing "e instanceof t.Path ||" in inst/htmlwidgets/build/lfx-search/lfx-search-prod.js

Tested search with addMarkers and addCircleMarkers in R 4.3.2

allow searching of circle markers as per trafficonese#143
@trafficonese
Copy link
Owner

Thank you, but this should be addressed in the upstream repo, as the -prod.js files are automatically created, when building the JS-sources.

But can you maybe open a PR for it at leaflet-search
I think this is the line, where it should be removed:
https://github.com/stefanocudini/leaflet-search/blob/d29c5392b33cc31b338c3d17b5f8532fef5eae48/src/leaflet-search.js#L556C18-L556C45

@trafficonese
Copy link
Owner

And anyway, I think this is working already with the current Github version.

Could you install the latest version with remotes::install_github("trafficonese/leaflet.extras")

and then test this example:

library(shiny)
library(leaflet)
library(leaflet.extras)

cities <- read.csv(textConnection("
City,Lat,Long,Pop
Boston,42.3601,-71.0589,645966
Hartford,41.7627,-72.6743,125017
New York City,40.7127,-74.0059,8406000
Philadelphia,39.9500,-75.1667,1553000
Pittsburgh,40.4397,-79.9764,305841
Providence,41.8236,-71.4222,177994
"))

ui <- fluidPage(
  leafletOutput("map"),
  actionButton("clearsearchmarker", "Clear Search Marker")
)

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet(cities) %>% addTiles() %>%
      addCircleMarkers(lng = ~Long, lat = ~Lat,
                       radius = 10, popup = ~City, 
                       label = ~City,
                       group = "cities") %>%
      addSearchFeatures(
        targetGroups = "cities", options = searchFeaturesOptions(
        ))
  })
  
  observeEvent(input$clearsearchmarker, {
    leafletProxy("map") %>%
      clearSearchFeatures()
  })
}
shinyApp(ui, server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants