Created
January 13, 2015 15:36
-
-
Save obojdi/e001850fd5fedabf7348 to your computer and use it in GitHub Desktop.
Coordinates from string address
This file contains hidden or 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
$('.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