From 75d079b3443fa65777e4183f083a21cd36dac5a6 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Tue, 23 Feb 2021 21:41:54 -0600 Subject: it works POG???????? --- csci4131/hw3/contacts.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'csci4131') diff --git a/csci4131/hw3/contacts.js b/csci4131/hw3/contacts.js index 8701aae..e5fffc2 100644 --- a/csci4131/hw3/contacts.js +++ b/csci4131/hw3/contacts.js @@ -113,7 +113,7 @@ function addPointsSearch(locations, isOther) { for (x in locations) { var marker; if (isOther) { - if (google.maps.geometry.spherical.computeDistanceBetween(locations[x].geometry.location, center) < parseInt(otherRadius)) { + if (google.maps.geometry.spherical.computeDistanceBetween(locations[x].geometry.location, map.getCenter()) < parseInt(otherRadius)) { marker = new google.maps.Marker({ map, title: locations[x].name, @@ -135,14 +135,15 @@ function addPointsSearch(locations, isOther) { }, }); } - - marker.addListener('click', function () { - if (!this.infoWindow) { - this.infoWindow = new google.maps.InfoWindow({ - content: this.data.content, - }); - this.infoWindow.open(map, this); - } - }) + if (marker) { + marker.addListener('click', function () { + if (!this.infoWindow) { + this.infoWindow = new google.maps.InfoWindow({ + content: this.data.content, + }); + this.infoWindow.open(map, this); + } + }) + } } } -- cgit v1.2.3