diff --git a/portfolio/src/main/webapp/maps.html b/portfolio/src/main/webapp/maps.html index fff71c1..860e758 100644 --- a/portfolio/src/main/webapp/maps.html +++ b/portfolio/src/main/webapp/maps.html @@ -2,7 +2,7 @@ Map - + @@ -17,7 +17,34 @@

My Notable Locations

-
+
+ + +
+ + + + +
+ + + + + + + + +
+
+ +
+
+
diff --git a/portfolio/src/main/webapp/script.js b/portfolio/src/main/webapp/script.js index 84c2b9b..3859b23 100644 --- a/portfolio/src/main/webapp/script.js +++ b/portfolio/src/main/webapp/script.js @@ -54,7 +54,6 @@ function addRandomDestination() { async function setPage() { const loginResponse = await fetch('/login', {method: 'POST'}); - if (loginResponse.ok) { const loginJson = await loginResponse.json(); addLogInOutButton(loginJson.url, loginJson.isLoggedIn); @@ -180,25 +179,182 @@ function shouldHideElement(container, hide) { } } +let map; function initMap() { const tokyo = {lat: 35.668, lng: 139.723}; const hachi = {lat: 35.659107, lng: 139.700653}; - const map = new google.maps.Map(document.getElementById('map'), { - center: tokyo, - zoom: 12 - }); + map = new google.maps.Map( + document.getElementById('map'), + {center: tokyo, zoom: 12}); const marker = new google.maps.Marker({position: hachi, map: map}) - hachiString = '

Statue of Hachiko

' + - '

a very good boi

' + - '

For actual info on Hachiko, visit his' + - ' Wikipedia page ' + - '

'; + hachiString = '

Statue of Hachiko

' + + '

a very good boi

' + + '

For actual info on Hachiko, visit his' + + ' Wikipedia page ' + + '

'; var infowindow = new google.maps.InfoWindow({content: hachiString}); marker.addListener('click', function() { infowindow.open(map, marker); - }) + }); + + new AutocompleteDirectionsHandler(map); +} + +function addMarker() { + const shouldAddMarker = document.getElementById('add-marker').value + + if (shouldAddMarker === 'true') { + map.addListener('click', function(mapsMouseEvent) { + const newMarker = + new google.maps.Marker({position: mapsMouseEvent.latLng, map: map}); + }); + } + else { + google.maps.event.clearListeners(map, 'click'); + } +} + +// START OF DIRECTIONS CODE + +// This example requires the Places library. Include the libraries=places +// parameter when you first load the API. For example: +//