Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created April 26, 2015 06:13
Show Gist options
  • Save d1i1m1o1n/60167ccd429ab2ea3e7b to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/60167ccd429ab2ea3e7b to your computer and use it in GitHub Desktop.
Получаем osm_id по координатам
/**
* Получаем osm_id по координатам
* @param {string} lat lat
* @param {string} lon lon
* @return {int} osm_id
*/
function get_osmid_by_lat_lon(lat, lon){
jQuery.ajax({
url: 'http://overpass-api.de/api/interpreter',
type: 'POST',
dataType: 'json',
data: {
data: '[timeout:5][out:json];way(around:15.0,'+lat+','+lon+');out;'
},
success: function(data, textStatus, xhr) {
return data.elements[0].id;
},
error: function(xhr, textStatus, errorThrown) {
alert('get_osmid_by_lat_lon - error');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment