1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| function initialize() {
var opts = {
center: new google.maps.LatLng(45.76161017250319, 6.284972881353269),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), opts);
geocoder = new google.maps.Geocoder();
google.maps.event.addListener(map, 'click', function(event) {
getAdressLocation(event.latLng);
if (markers_list.length != 0) {
clearMap();
}
calculatDistMarkers(event.latLng);
});
}
function calculatDistMarkers(location) {
var list = document.getElementById('travelmode');
travelmodev = list.options[list.selectedIndex].value;
query(location, travelmodev);
query2(location, travelmodev);
}
function query(location, travelm) {
if( location != '' ) {
alert(location);
var lat = parseFloat(location.lat());
var lng = parseFloat(location.lng());
var latlng = new google.maps.LatLng(lat, lng);
alert(latlng);
useradress=latlng;
}
if( travelm != '' ) travelmodev=travelm;
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [useradress],
destinations: destinations,
travelMode: google.maps.TravelMode[travelmodev],
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
} |
Partager