forked from fredzhou93/Amazon-Flex-App
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.js
More file actions
55 lines (47 loc) · 1.66 KB
/
Copy pathservice.js
File metadata and controls
55 lines (47 loc) · 1.66 KB
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
let packageList = [{
"name": "package1",
"startLocation": "Locker1",
"endLocation": "Locker2"
}, {
"name": "package2",
"startLocation": "Locker4",
"endLocation": "Locker5"
}]
let startLockerList = ["Locker1", "Locker3", "Locker5"]
let endLockerList = ["Locker2", "Locker4", "Locker6"]
function checkPakcage(startLockerList, endLockerList) {
let okPackageList = [];
packageList.forEach((package) => {
if (startLockerList.contains(package.startLocation) && endLockerList.contains(package.endLocation)) {
okPackageList.push(package);
}
});
console.log(okPackageList);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
}
function geo(address, callback) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var location = results[0].geometry.location;
callback(location);
}
});
}
function handleLocation(location) {
//do your stuff here
alert(location)
}
initialize();
geo("new york", handleLocation);
</script>
</head>
<body>