, - iOS, apple-mobile-web-app-capable, navigator.geolocation. , . HTML .
( apple-mobile-web-app-capable set):
navigator.geolocation.getCurrentPosition( function ( position ) {
alert( 'yay!' );
},
function ( error ) {
alert( 'boo! error: ' + error.message );
} );
, , . .
} )( jQuery, window.navigator.geolocation );
, , .text() , .getJSON() :
function (data) {
$(function () {
$('#zip').text(data.address.postalcode);
});
}
Try:
function (data) {
$('#zip').text(data.address.postalcode);
}
, :
( function ( $, geolocation ) {
if (geolocation) {
geolocation.getCurrentPosition( function ( position ) {
$.getJSON(
"http://ws.geonames.org/findNearestAddressJSON?callback=?",
{
lat : position.coords.latitude,
lng : position.coords.longitude
},
function (data) {
$('#zip').text(data.address.postalcode);
}
);
});
}
} )( jQuery, window.navigator.geolocation );