Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address/ landmark search #75

Open
alepuccetti opened this issue Oct 26, 2017 · 5 comments
Open

Address/ landmark search #75

alepuccetti opened this issue Oct 26, 2017 · 5 comments

Comments

@alepuccetti
Copy link

Like the eye icon that allows you to go to specific coordinates, it would be great to have another button that allows you to search for addresses and landmark. Like in openstreet map.

@nreese
Copy link
Owner

nreese commented Oct 26, 2017

Is there an open API for converting landmarks into lat/lons

@alepuccetti
Copy link
Author

After some digging, I found this API: http://nominatim.openstreetmap.org/search?q="london"&format=json, which returns results in json (other formats are available, see http://wiki.openstreetmap.org/wiki/Nominatim).

Example:

[
  {
    "place_id": "179118272",
    "licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
    "osm_type": "relation",
    "osm_id": "65606",
    "boundingbox": [
      "51.2867602",
      "51.6918741",
      "-0.5103751",
      "0.3340155"
    ],
    "lat": "51.5073219",
    "lon": "-0.1276474",
    "display_name": "London, Greater London, England, United Kingdom",
    "class": "place",
    "type": "city",
    "importance": 0.31637239413505,
    "icon": "http://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png"
  }
  ...
]

We could use the first value (best effort) or we could run the query after a second of the last character is typed and show a list of value and then the user can select the one he wants to go to.

@alepuccetti
Copy link
Author

@nreese I start working on this feature in this branch. I am not a JS expert so any feedbacks you can provide will be very much appreciated.

I added a new 🔍 button to implement search. For now, I would like to do the API call and go to the coordinates of the first result. Then, it would be interesting to show in a drop-down slider the top n result (so that the user can have multiple choices) by firing the API query after 1 second of the last typed character and set the view to the user selected entry.

@alepuccetti
Copy link
Author

Also, the API returns a bounding box of the address/landmark and it would be cool to extrapolate the zoom level from that.

@alepuccetti
Copy link
Author

I found this work about implementing search in in leaflet, but I cannot find a way to integrate it into the map. https://github.com/perliedman/leaflet-control-geocoder/tree/master

Maybe for someone more expert than me in JS it is an easy task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants