传单搜索框未返回任何结果

时间:2020-02-04 08:31:42

标签: r r-leaflet

我无法从传单搜索框中获取示例数据。 我没有收到任何错误消息,但是搜索框中的“计时器”一直在旋转,并且没有返回任何结果。

带有示例数据的网站上的输出地图对我有用: https://rpubs.com/bhaskarvk/leaflet-search
但是,当我运行本地代码时,在firefox的Rstudio-viewer中,搜索框正常工作。

运行最新的leaflet和leaflet.extras

有人可以验证/重现我的问题,还是仅我一个人?

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版本3.6.2(2019-12-12)平台:x86_64-w64-mingw32 / x64(64位)运行在:Windows 10 x64(build 18362)

Matrix产品:默认

语言环境:[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

附加的基本软件包:[1]统计图形grDevices utils
数据集方法基础

其他附带的软件包:[1] leaflet.extras_1.0.0 leaflet_2.0.3.9000

通过名称空间(未附加)加载:[1] Rcpp_1.0.3
leaflet.providers_1.9.0 packrat_0.5.0摘要_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]闪亮_1.4.0
yaml_2.2.0 httpuv_1.5.2 fastmap_1.0.1
editor_3.6.2 [21] htmltools_0.4.0

1 个答案:

答案 0 :(得分:1)

找到了答案。 这似乎是一个已知的问题...

https://github.com/bhaskarvk/leaflet.extras/issues/143#issuecomment-450461384

下面描述的解决方案对我有用:

我弄清楚了如何使用CircleMarkers进行搜索 (删除路径检查),您必须进入R库路径: R库路径#\ leaflet.extras \ htmlwidgets \ build \ lfx-search \

打开lfx-search-prod.js并搜索“ e instanceof t.Path ||”和 然后将其删除并保存文件。您的CircleMarker搜索应该可以正常工作 现在