传单搜索框 returns 无结果
leaflet searchbox returns no result
我无法从传单搜索框中获取示例数据。
我没有收到任何错误,但搜索框中的 'timer' 一直在旋转,并且没有返回任何结果。
带有示例数据的网站上的输出地图, 对我有用:
https://rpubs.com/bhaskarvk/leaflet-search
但是,当我 运行 本地代码时,在 firefox 的 Rstudio-viewer 中,搜索框 not working.
运行最新传单和leaflet.extras
谁能verify/reproduce我的问题,还是只是我的问题?
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')
会话信息:
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 base
other 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
找到答案..
这似乎是一个已知问题...
https://github.com/bhaskarvk/leaflet.extras/issues/143#issuecomment-450461384
下面描述的解决方案对我有用:
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
我无法从传单搜索框中获取示例数据。 我没有收到任何错误,但搜索框中的 'timer' 一直在旋转,并且没有返回任何结果。
带有示例数据的网站上的输出地图, 对我有用:
https://rpubs.com/bhaskarvk/leaflet-search
但是,当我 运行 本地代码时,在 firefox 的 Rstudio-viewer 中,搜索框 not working.
运行最新传单和leaflet.extras
谁能verify/reproduce我的问题,还是只是我的问题?
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')
会话信息:
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
找到答案.. 这似乎是一个已知问题...
https://github.com/bhaskarvk/leaflet.extras/issues/143#issuecomment-450461384
下面描述的解决方案对我有用:
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