Closed yfreemark closed 8 years ago
Leaflet Search plugin can search through the properties of your station and lines data and then zoom to that feature.
ok, i tried really hard to get this to work... and it just doesn't show up. is it because it needs to have a way of searching the geojsons? does it know how to do that automatically? i think i just broke the code with it! Whatever the case, installing this is not a huge deal in the short term.
I've never used this plugin before and I didn't spend time on it last night so that's why I commented out the code. I believe that you have to tell the plugin how to read your layers and we haven't done that yet.
I've tried to add the search repeatedly to the code but I can't figure out how to do it, sadly. I left the code detritus in app.js from lines 193-210. If you have any ideas on how to incorporate this, that would be amazing!
I've got a working search box, but it doesn't yet zoom to that feature when you click on it. We also need to decide how to style the search results. Essentially any property that's shown in a feature's popup can also be part of the search results.
It now pans to the search result, but it doesn't yet zoom or center on the search result.
OK, I worked on the search styling. Looks good to me.
I think we don't need to show any of the information in the search results other than the name and the region. Is that possible? Would doing that allow more than five search results at a time?
The 5 search results is fixed by the searchCtrl.maxResultLength
property in the makeMap()
function.
You would want to give some more information about the search result if you decide to add in existing stations. However, there are so many that it's kind of annoying to type in "New York City" and see 400+ stations show up, so I recommend leaving out existing stations from the search (it's currently set up to keep them out).
is it possible to add a search bar that allows people to search for items on the map?