From 510f8d68c91414cea5f6e8fd360616f857df1db9 Mon Sep 17 00:00:00 2001
From: RossTheRoss
Date: Thu, 25 Feb 2021 10:15:00 -0600
Subject: e
---
csci4131/hw3/MyForm.html | 5 ++++
csci4131/hw3/contacts.js | 63 ++++++++++++++++++++++++++++++++++++++++++--
csci4131/hw3/myContacts.html | 16 ++++++-----
csci4131/hw3/style.css | 34 +++++++++++++++---------
4 files changed, 96 insertions(+), 22 deletions(-)
diff --git a/csci4131/hw3/MyForm.html b/csci4131/hw3/MyForm.html
index 261d8df..4e2760d 100644
--- a/csci4131/hw3/MyForm.html
+++ b/csci4131/hw3/MyForm.html
@@ -5,6 +5,7 @@
There is no form
+
+
+
diff --git a/csci4131/hw3/contacts.js b/csci4131/hw3/contacts.js
index 68d5731..8518ef6 100644
--- a/csci4131/hw3/contacts.js
+++ b/csci4131/hw3/contacts.js
@@ -1,5 +1,3 @@
-document.getElementById("bigboi").classList.add("isntRotating");
-
function change(small, row) {
document.getElementsByClassName("smol")[row].src = small;
}
@@ -25,6 +23,19 @@ function check(value) {
let map;
var center = { lat: 44.9727, lng: -93.23540000000003 };
function initMap() {
+ if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(
+ (position) => {
+ curLoc = {
+ lat: position.coords.latitude,
+ lng: position.coords.longitude,
+ };
+ },
+ () => {
+ alert("Geolocation failed. Directions will not work.");
+ }
+ )
+ }
map = new google.maps.Map(document.getElementById("map"), {
center: center,
zoom: 14,
@@ -157,6 +168,54 @@ function deleteMarkers() {
searchMarker = [];
}
+var curLoc, directionsService, directionsRenderer;
function directions () {
+ directionsService = new google.maps.DirectionsService();
+ directionsRenderer = new google.maps.DirectionsRenderer();
+ document.getElementById("transitList").textContent = "";
+ directionsRenderer.setPanel(document.getElementById("transitList"));
+ directionsRenderer.setMap(map);
+ var selectedMode = document.getElementById('means').value;
+ var dest = {
+ query: document.getElementById("destination").value,
+ fields: ['name', 'geometry'],
+ };
+ service = new google.maps.places.PlacesService(map);
+ service.findPlaceFromQuery(dest, function (results, status) {
+ if (status === google.maps.places.PlacesServiceStatus.OK) {
+ console.log(results);
+ doDirections(results[0]);
+ }
+ });
+}
+
+function doDirections(input) {
+ var means;
+ var mean = document.getElementsByName('means');
+ for (var i = 0; i < mean.length; i++) {
+ if (mean[i].checked) {
+ means = mean[i].value;
+ }
+ }
+ var request = {
+ origin: curLoc,
+ destination: input.geometry.location,
+ // Note that JavaScript allows us to access the constant
+ // using square brackets and a string value as its
+ // "property."
+ travelMode: google.maps.TravelMode[means]
+ };
+ directionsService.route(request, function (result, status) {
+ if (status == 'OK') {
+ directionsRenderer.setDirections(result);
+ }
+ });
}
+
+function initForm() {
+ map = new google.maps.Map(document.getElementById("formap"), {
+ center: center,
+ zoom: 14,
+ });
+}
\ No newline at end of file
diff --git a/csci4131/hw3/myContacts.html b/csci4131/hw3/myContacts.html
index 90f43c9..3eae9db 100644
--- a/csci4131/hw3/myContacts.html
+++ b/csci4131/hw3/myContacts.html
@@ -71,15 +71,15 @@
Home Page |
-
+
-
-
+
+
+