aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw3/contacts.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--csci4131/hw3/contacts.js59
1 files changed, 56 insertions, 3 deletions
diff --git a/csci4131/hw3/contacts.js b/csci4131/hw3/contacts.js
index 0e9b8bb..94340b2 100644
--- a/csci4131/hw3/contacts.js
+++ b/csci4131/hw3/contacts.js
@@ -1,8 +1,61 @@
-function change(big, small, row) {
- // document.getElementById("bigboi").src = big;
- document.getElementById("smol" + row).src = small;
+function change(small, row) {
+ document.getElementsByClassName("smol")[row].src = small;
}
function lucky() {
var image = ["carlson.jpg", "johnston.jpg", "morrill.jpg", "shepherd.jpg", "snyder.jpg", "walter.jpg"];
document.getElementById("bigboi").src = image[Math.floor(6 * Math.random())];
}
+let map;
+function initMap() {
+ map = new google.maps.Map(document.getElementById("map"), {
+ center: { lat: 44.9727, lng: -93.23540000000003 },
+ zoom: 14,
+ });
+
+ var service = new google.maps.places.PlacesService(map);
+ entries = document.getElementsByClassName("entry");
+ locations = [];
+ for (e=0; e<entries.length; e+=1) {
+ var kludge = 0;
+ var request = {
+ query: entries[e].getElementsByClassName("address")[0].textContent,
+ fields: ['name', 'geometry'],
+ };
+ service.findPlaceFromQuery(request, function (results, status) {
+ if (status === google.maps.places.PlacesServiceStatus.OK) {
+ locations[kludge++] = results[0];
+ }
+ if (kludge == entries.length) {
+ addPoints(locations);
+ }
+ });
+ }
+}
+
+function addPoints(locations) {
+ for (x in locations) {
+ newEntry = document.getElementsByClassName("entry")[x];
+ var marker = new google.maps.Marker({
+ map,
+ position: locations[x].geometry.location,
+ title: newEntry.getElementsByClassName("name")[0].textContent,
+ data : {
+ content: "<div class='id'>" +
+ "<b>" + newEntry.getElementsByClassName("name")[0].textContent + "</b>" + "<br>" +
+ newEntry.getElementsByClassName("category")[0].textContent + "<br>" +
+ newEntry.getElementsByClassName("room")[0].textContent + " " + newEntry.getElementsByClassName("street")[0].textContent + "<br>" +
+ newEntry.getElementsByClassName("city")[0].textContent +
+ "</div>",
+ }
+ });
+ marker.addListener('click', function () {
+ if (!this.infoWindow) {
+ this.infoWindow = new google.maps.InfoWindow({
+ content: this.data.content,
+ // content: newEntry.getElementsByClassName("address")[0],
+ });
+ }
+ this.infoWindow.open(map, this);
+ })
+ }
+} \ No newline at end of file