-
Notifications
You must be signed in to change notification settings - Fork 0
/
clickController.js
68 lines (39 loc) · 1.58 KB
/
clickController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function initMap() {
console.log(" monkeeees");
var geocoder = new google.maps.Geocoder();
document.getElementById('submit').addEventListener('click', function() {
geocodeAddress(geocoder);
});
}
var addresses = [];
var coordinates = [];
var i = 0;
var display = "";
function geocodeAddress(geocoder) {
var inputString = document.getElementById('address').value;
addresses = [];
addresses = inputString.split(';')
var addressesL = addresses.length;
console.log("addresses length is " + addresses.length);
setTimeout(function () { // call a 3s setTimeout when the loop is called\
var currentaddress = addresses[i];
geocoder.geocode({'address': currentaddress}, function(results, status) {
if (status === 'OK') {
var target = results[0].geometry.location;
var targetStr = target.toString()
var targetStrT = targetStr.replace(/[()]/g,"");
console.log(targetStrT);
display = display + targetStrT + ";" ;
// display = display + ";" + targetStrT;
document.getElementById('display').innerHTML = display;
coordinates.push(targetStrT)
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
i++;
if(i<addressesL)
{geocodeAddress(geocoder);}
}, 3000)
}
// test user input: 7301 Buttercup Rd,Sykesville Maryland;7555 Waterloo Rd,Jessup Maryland;30420 Revells Neck Rd,Westover Maryland