-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Return lat.long #75
Comments
Hi @marcoamadori, One way to get latitude and longitude is to read them off the results list. Each DOM element in the list have latitude and longitude properties attached to them, which we use internally to know what to do with a selected result. But I realize that this is not ideal (and it's not documented) and we need to expose a much better way of working with the results that come back. If you let us know what you need we can start to form a solution. Thanks for raising the question! |
Hi @louh thanks for your answer.
What I'd like to do is a biketrip-planner that integrate the Valhalla algorithm for route creation with the Geocoder address search. I've added two Geocoder and a "Create Route" Button that launches the function of route creation. My idea is to find the starting and arrival point with the two geocoders controls, and pass the coordinates to the Valhalla script in order to create the route. |
The geocoder controls do store selected results coordinates internally, so one way of getting that out is like so: var selectedResult1 = geocoder1._results.querySelector('.leaflet-pelias-selected').coords;
var selectedResult2 = geocoder2._results.querySelector('.leaflet-pelias-selected').coords; Let me know if that helps. By the way, the last couple of days I am proposing an event-based way of getting information out of certain actions. (See this branch here.) In this proposal, you can do something like this: var latlng1, latlng2;
geocoder1.on('select', function (event) {
latlng1 = event.latlng;
});
geocoder2.on('select', function (event) {
latlng2 = event.latlng;
}); |
Hi @marcoamadori, The Let me know if this helps! |
Great! it works! Thank you very much :) |
How can I get latitude and longitude from the Geocoder?
I want to pass them as var.
The text was updated successfully, but these errors were encountered: