Created
April 26, 2015 06:13
-
-
Save d1i1m1o1n/60167ccd429ab2ea3e7b to your computer and use it in GitHub Desktop.
Получаем osm_id по координатам
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Получаем 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