Skip to content

Instantly share code, notes, and snippets.

@obojdi
Created January 13, 2015 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obojdi/e001850fd5fedabf7348 to your computer and use it in GitHub Desktop.
Save obojdi/e001850fd5fedabf7348 to your computer and use it in GitHub Desktop.
Coordinates from string address
$('.geocode').click(function(e){
e.preventDefault();
var address = $('[name="address"]').val();
console.log(address)
$.ajax(
{
url:'http://geocode-maps.yandex.ru/1.x/?format=json&geocode='+address
}
).success(function(data){
var resp = data.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos
console.log('coordinates: '+resp)
var x = resp.split(" ")[0]
var y = resp.split(" ")[1]
$('input[name="x"]').val(x);
$('input[name="y"]').val(y);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment