function myplace()
{
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat23 = position.coords.latitude;
var lon23 = position.coords.longitude;
alert("Ваши координаты" + " " + lat23+' '+lon23);
});
} else
{
alert("Geolocation API не поддерживается в вашем браузере");
}
}
function geocoding()
{
var my_adress;
var api_key = 'AIzaSyAsuS1MqzRBzRv1HRrfrlyoMRlkrVXEx0g';
var cordinats = [53.8652367, 27.650465399999998];
var loctype = 'ROOFTOP';
var restype = 'street_address';
var position = cordinats.join(",");
var data = {latlng: position, location_type: loctype, result_type: restype, key: api_key};
$.ajax({
method: "GET",
url: "https://maps.googleapis.com/maps/api/geocode/json",
data: data,
dataType: 'json',
success: function (result) {
console.log(result)
my_adress = result.results[0].formatted_address;
alert("Вы здесь" + " " + "<" + " " + my_adress + " " + ">");
},
error: function (err) {
console.log("Ошибка сервера")
}
})
}
function myplace()
{
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
geocoding(position.coords.latitude, position.coords.longitude);
});
} else
{
alert("Geolocation API не поддерживается в вашем браузере");
}
}
function geocoding(lat, lon)
{
var my_adress;
var api_key = 'AIzaSyAsuS1MqzRBzRv1HRrfrlyoMRlkrVXEx0g';
var cordinats = [lat, lon];
var loctype = 'ROOFTOP';
var restype = 'street_address';
var position = cordinats.join(",");
var data = {latlng: position, location_type: loctype, result_type: restype, key: api_key};
$.ajax({
method: "GET",
url: "https://maps.googleapis.com/maps/api/geocode/json",
data: data,
dataType: 'json',
success: function (result) {
console.log(result)
my_adress = result.results[0].formatted_address;
alert("Вы здесь" + " " + "<" + " " + my_adress + " " + ">");
},
error: function (err) {
console.log("Ошибка сервера")
}
})
}
myplace(); // Вызываем всё это дело.
function myplace()
{
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat23 = position.coords.latitude;
var lon23 = position.coords.longitude;
return [lat23, lon23];
});
} else
{
alert("Geolocation API не поддерживается в вашем браузере");
}
}
function geocoding()
{
var my_adress;
var api_key = 'AIzaSyAsuS1MqzRBzRv1HRrfrlyoMRlkrVXEx0g';
var cordinats = myplace();
var loctype = 'ROOFTOP';
var restype = 'street_address';
var position = cordinats.join(",");
var data = {latlng: position, location_type: loctype, result_type: restype, key: api_key};
$.ajax({
method: "GET",
url: "https://maps.googleapis.com/maps/api/geocode/json",
data: data,
dataType: 'json',
success: function (result) {
console.log(result)
my_adress = result.results[0].formatted_address;
alert("Вы здесь" + " " + "<" + " " + my_adress + " " + ">");
},
error: function (err) {
console.log("Ошибка сервера")
}
})
}