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 + " " + ">");
/-----------------------GMaps Initialization-------------------------------/
function initMap() {
var latlng = new google.maps.LatLng(lat, lon);
var map;
var mapOptions = {
center: latlng,
zoom: 14,
mapTypeControl: false,
streetViewControl: false,
styles: [{"featureType":"water","stylers":[{"saturation":43},{"lightness":-11},{"hue":"#0088ff"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"hue":"#ff0000"},{"saturation":-100},{"lightness":99}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#808080"},{"lightness":54}]},{"featureType":"landscape.man_made","elementType":"geometry.fill","stylers":[{"color":"#ece2d9"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#ccdca1"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#767676"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#ffffff"}]},{"featureType":"poi","stylers":[{"visibility":"off"}]},{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#b8cb93"}]},{"featureType":"poi.park","stylers":[{"visibility":"on"}]},{"featureType":"poi.sports_complex","stylers":[{"visibility":"on"}]},{"featureType":"poi.medical","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","stylers":[{"visibility":"simplified"}]}]
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"Вы знаходитесь в данном месте"
});
}
initMap();
},
error: function (err) {
console.log("Ошибка сервера")
}
})
}
computeTotalDistance
Так вот ведь именно она считает кратчайшее расстояние в км. И там ведь нужно сравнивать значение функции, только потом уже инициализировать функцию построения дороги. drivingRoute
и у скачанной темы
Всё равно не понятно , почему она дочерняя