mirror of
https://github.com/neogeek23/neogeek23.github.io.git
synced 2026-02-04 10:58:21 +00:00
Update MapScript.js
This commit is contained in:
parent
58cb5bcf5b
commit
b276fd7f43
@ -1,29 +1,54 @@
|
|||||||
let map;
|
|
||||||
function initMap() {
|
function initMap() {
|
||||||
map = new google.maps.Map(document.getElementById('map'), {
|
let directionsService = new google.maps.DirectionsService;
|
||||||
center: {lat: 32.776, lng: -96.797},
|
let directionsDisplay = new google.maps.DirectionsRenderer;
|
||||||
zoom: 10
|
|
||||||
|
let map = new google.maps.Map(document.getElementById('map'), {
|
||||||
|
center: {lat: 32.9608558, lng: -96.8530005},
|
||||||
|
zoom: 13
|
||||||
});
|
});
|
||||||
|
|
||||||
let home;
|
// let home = new google.maps.Marker({
|
||||||
home = new google.maps.Marker({
|
// position: {lat: 32.9608558, lng: -96.8530005},
|
||||||
position: {lat: 32.9608558, lng: -96.8530005},
|
// map: map,
|
||||||
map: map,
|
// title: 'Home'
|
||||||
title: 'Home'
|
// });
|
||||||
});
|
//
|
||||||
|
// let globe_runnner= new google.maps.Marker({
|
||||||
|
// position: {lat: 32.972469, lng: -96.830857},
|
||||||
|
// map: map,
|
||||||
|
// title: 'Globe Runner'
|
||||||
|
// });
|
||||||
|
|
||||||
let globe_runnner;
|
directionsDisplay.setMap(map);
|
||||||
globe_runnner = new google.maps.Marker({
|
document.getElementById('submit').addEventListener('click', function() {
|
||||||
position: {lat: 32.972469, lng: -96.830857},
|
calculateAndDisplayRoute(directionsService, directionsDisplay);
|
||||||
map: map,
|
|
||||||
title: 'Globe Runner'
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let unifocus;
|
function calculateAndDisplayRoute(directionsService, directionsDisplay){
|
||||||
unifocus = new google.maps.Marker({
|
directionsService.route({
|
||||||
position: {lat: 32.9194354, lng: -96.9292158},
|
origin: document.getElementById('start').value,
|
||||||
map: map,
|
destination: document.getElementById('end').value,
|
||||||
title: 'Unifocus'
|
optimizeWaypoints: true,
|
||||||
|
travelMode: 'DRIVING'
|
||||||
|
}, function(response, status) {
|
||||||
|
if (status === 'OK') {
|
||||||
|
directionsDisplay.setDirections(response);
|
||||||
|
let route = response.routes[0];
|
||||||
|
let summaryPanel = document.getElementById('directions-panel');
|
||||||
|
summaryPanel.innerHTML = '';
|
||||||
|
// For each route, display summary information.
|
||||||
|
for (let i = 0; i < route.legs.length; i++) {
|
||||||
|
let routeSegment = i + 1;
|
||||||
|
summaryPanel.innerHTML += '<b>Route Segment: ' + routeSegment +
|
||||||
|
'</b><br>';
|
||||||
|
summaryPanel.innerHTML += route.legs[i].start_address + ' to ';
|
||||||
|
summaryPanel.innerHTML += route.legs[i].end_address + '<br>';
|
||||||
|
summaryPanel.innerHTML += route.legs[i].distance.text + '<br><br>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.alert('Directions request failed due to ' + status);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user