leaflet.extras icon indicating copy to clipboard operation
leaflet.extras copied to clipboard

Leaflet.extras addSearchFeatures not rendering

Open AMoss22 opened this issue 6 years ago • 16 comments

AMoss22 avatar May 24 '18 16:05 AMoss22

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("<P><B>Hint!</B> Search for ...

  • New York
  • Boston
  • Hartford
  • Philadelphia
  • Pittsburgh
  • Providence
</P>", position='bottomright')

AMoss22 avatar May 24 '18 16:05 AMoss22

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?

ramnathv avatar Jun 08 '18 05:06 ramnathv

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.

schloerke avatar Jun 08 '18 14:06 schloerke

Thanks for the update @schloerke!

ramnathv avatar Jun 08 '18 15:06 ramnathv

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.

tim-salabim avatar Jun 08 '18 16:06 tim-salabim

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

AMoss22 avatar Jul 24 '18 10:07 AMoss22

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.

erstearns avatar Jul 27 '18 09:07 erstearns

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")%>%

mhaditama26 avatar Aug 28 '18 05:08 mhaditama26

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

yzjiangyang avatar Aug 29 '18 07:08 yzjiangyang

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.

ryanscharf avatar Oct 17 '18 18:10 ryanscharf

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

bhaskarvk avatar Nov 01 '18 15:11 bhaskarvk

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

yzjiangyang avatar Nov 07 '18 18:11 yzjiangyang

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

yzjiangyang avatar Dec 01 '18 02:12 yzjiangyang

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

TacticalFate avatar Dec 29 '18 03:12 TacticalFate

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

ryanscharf avatar Jan 03 '19 17:01 ryanscharf

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!

Vicellken avatar Feb 25 '19 09:02 Vicellken