trafficonese / leaflet.extras

Extra functionality for leaflet R package.
https://trafficonese.github.io/leaflet.extras/
GNU General Public License v3.0
213 stars 74 forks source link

Leaflet.extras addSearchFeatures not rendering #143

Closed AMoss22 closed 5 months ago

AMoss22 commented 6 years ago

Hi I used one of your examples to add search feature code below. This runs and produces the map with the search box but when I type in New York (or any of the other city names) it location is not found. Do you have any ideas why this might be. Many thanks This is the example I tried

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("

Hint! Search for ...

", position='bottomright')

ramnathv commented 6 years ago

I believe this is related to https://github.com/stefanocudini/leaflet-search/issues/196. @schloerke I see that leaflet.extras is still using v 2.3.7 of leaflet-search, while the current version is 2.9.0. Any reasons not to switch to the latest version?

schloerke commented 6 years ago

The circle marker issue looks to be fixed without testing.

https://github.com/stefanocudini/leaflet-search/issues/196 is not fixed as Path has not removed.

Once Path is removed, I'll make a PR.

ramnathv commented 6 years ago

Thanks for the update @schloerke!

tim-salabim commented 6 years ago

For what it's worth, @ramnathv I can confirm @schloerke 's comment. About two weeks ago I updated a local clone of leaflet.extras to the latest version of leaflet-search and still had to remove the Path bit to get it working properly.

AMoss22 commented 6 years ago

Thank you all for your comments, I'm a bit confused what I have to do to get this function to work. It clearly works in the Rpubs example. I am using R studio version 1.1.183, R version 3.4.2, leaflet version 2.0.1 and leaflet.extras version 1.0.0. I have tried to compare the html but it is very different.
Any help would be appreciated

erstearns commented 6 years ago

I am also having the same issue with all three addSearch options. addSearchUSCensusBureau and addSearchOSM result in the search icon being present on the leaflet map, however addSearchGoogle does not. Also puzzled by the fact that it is working great in the Rpubs example. I am running RStudio version: 1.1.456, R version: 3.4.4, leaflet version 2.0.1.9 and leaflet.extras version 1.0.0. Not sure what could be driving the issue, but wanted to contribute information on my system to help diagnose the problem.

mhaditama26 commented 6 years ago

The feature you added has to have a label.. thus you can search it

addMarkers(yourfeature$Longitude, yourfeature$Latitude, label=yourfeature$name,popup = yourfeature$name, group = "yourfeature")%>%

yzjiangyang commented 6 years ago

@tim-salabim, how to remove the Path bit to get it working properly? leaflet extra Search Button does not work for me either.

ryanscharf commented 5 years ago

This still appears to be a problem with leaflet 2.0.2 and leaflet.extras 1.0.0. It seems to be recognized that CircleMarkers don't work, but I haven't been able to get the RPubs addSearchFeatures() example to work with addCircles() either.

bhaskarvk commented 5 years ago

I'll be resuming development of leaflet.extras in Dec and will tackle this in that round. Thanks!

yzjiangyang commented 5 years ago

@bhaskarvk How Can we remove the path to make CircleMarkers search button work properly? Thanks

yzjiangyang commented 5 years ago

I'll be resuming development of leaflet.extras in Dec and will tackle this in that round. Thanks!

@bhaskarvk Hi, Will you work on the leaflet search button in Dec? Thank you

TacticalFate commented 5 years ago

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

ryanscharf commented 5 years ago

@TacticalFate Are you editing the package files? Those directories don't exist for me.

Vicellken commented 5 years ago

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

Thank you! Your solution works for me!

trafficonese commented 5 months ago

I updated leaflet-search to v4.0.0 and addSearchFeatures should be working again.