Closed francislavoie closed 7 years ago
I managed to figure out how to build it with yarn install
.
I found an additional bug with my implementation in doing so, reverse
only returns a JSON object (since it's a single result) rather than an array, so I needed to wrap the result in an array before passing it to parse
.
I tested it with my application, and this seems to fix the issue for me.
Looking good to me. Thanks!
See #144 for discussion
I have not tested this, I don't have a proper dev environment to be able to build.
Overview of the changes:
data
argument for searching, it should get ignored as-is for other providers, it's only handled by thesearch
function overridden for the OSM and LocationIQ providers.data
when handling the click on the result list.data
when hittingENTER
when an item in the result list is selected. For this, I moved up theconst list
to before the check for theENTER
key, and I callselect()
on the currently selected item to get the result data.endpointReverse
which fills in the params for thereverse
API endpoint, i.e. theosm_id
andosm_type
. The function assumes that data that was passed throughparse
is what's given here, i.e. grabbing the params fromdata.raw
. This would probably fail if data from a different provider gets passed in, for example.osm_type
argument for thereverse
API, as the data in the result doesn't match what's expected in the query. I'm making the assumption here that the type can't be anything but the three listed there, because the OSM docs say[N|W|R]
are the accepted values.search
which callsendpointReverse
instead ofendpoint
ifdata
is provided to the search.I didn't write any additional tests, but I figure that it might make sense to do so, adding a case where a result from a previous test is passed to
search
.