Answer the question
In order to leave comments, you need to log in
How to determine which city is in a leafletjs map?
There is a map shown using leafletjs, how to do the same as on Yandex.taxi, when moving around the map, when different cities are shown in the display area, the list of taxi services changes?
Answer the question
In order to leave comments, you need to log in
The procedure is as follows:
Leaflet knows nothing about cities. But he knows about the coordinates. Obviously, you need to store the coordinates of cities and, when moving the map, look for those that fall into the current viewport.
To search for a city by coordinates, you can use the free Yandex Geocoder API https://tech.yandex.ru/maps/doc/geocoder/desc/conc...
I can offer kostylidze :) OpenWeatherMap also provides the name of the city along with the weather
navigator.geolocation.getCurrentPosition(function(position){
$http.get('http://api.openweathermap.org/data/2.5/weather?lat=' + position.coords.latitude + '&lon=' + position.coords.longitude + '&appid=API_KEY')
.success(function(location) {
$scope.city = location.name;
})
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question