I cannot get the sample data from a leaflet searchbox to work. I get no errors, but the 'timer' in the searchbox keeps spinning, and no results are returned.
The output-map on the website with the sample data, is working for me:
https://rpubs.com/bhaskarvk/leaflet-search
However, when I run the code local, in Rstudio-viewer of in firefox, the searchbox is not working.
Running the latest leaflet and leaflet.extras
Can someone verify/reproduce my issue, or is it just me?
library(leaflet)
library(leaflet.extras)
# Markers ----
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
"))
leaflet(cities) %>% addProviderTiles(providers$OpenStreetMap) %>%
addCircleMarkers(lng = ~Long, lat = ~Lat, weight = 1, fillOpacity=0.5,
radius = ~sqrt(Pop)/50 , popup = ~City, label=~City, group ='cities') %>%
addResetMapButton() %>%
addSearchFeatures(
targetGroups = 'cities',
options = searchFeaturesOptions(
zoom=12, openPopup = TRUE, firstTipSubmit = TRUE,
autoCollapse = TRUE, hideMarkerOnCollapse = TRUE )) %>%
addControl("<P><B>Hint!</B> Search for ...<br/><ul><li>New York</li><li>Boston</li><li>Hartford</li><li>Philadelphia</li><li>Pittsburgh</li><li>Providence</li></ul></P>",
position='bottomright')
sessionInfo:
R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale: [1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 [4] LC_NUMERIC=C LC_TIME=Dutch_Netherlands.1252
attached base packages: [1] stats graphics grDevices utils
datasets methods baseother attached packages: [1] leaflet.extras_1.0.0 leaflet_2.0.3.9000
loaded via a namespace (and not attached): [1] Rcpp_1.0.3
leaflet.providers_1.9.0 packrat_0.5.0 digest_0.6.23
later_1.0.0 [6] mime_0.8 R6_2.4.1
jsonlite_1.6 xtable_1.8-4 magrittr_1.5
[11] rlang_0.4.2 promises_1.1.0 tools_3.6.2
htmlwidgets_1.5.1 crosstalk_1.0.0 [16] shiny_1.4.0
yaml_2.2.0 httpuv_1.5.2 fastmap_1.0.1
compiler_3.6.2 [21] htmltools_0.4.0
found the answer.. it seems to be a knowsn issue...
https://github.com/bhaskarvk/leaflet.extras/issues/143#issuecomment-450461384
described solution below worked for me:
I figured out how to make the search work with the CircleMarkers (removing the path check), you have to go into your R library path : R Library path#\leaflet.extras\htmlwidgets\build\lfx-search\
Open lfx-search-prod.js and search for "e instanceof t.Path ||" , and then delete it and save the file. Your CircleMarker search should work now