-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.js
More file actions
41 lines (35 loc) · 788 Bytes
/
Copy pathstate.js
File metadata and controls
41 lines (35 loc) · 788 Bytes
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
let newState = function() {
let locations = [];
let lines = [];
let markers = [];
let addLocation = function(latlng) {
if(locations.length < 2) {
locations.push(latlng);
} else {
locations.shift();
locations.push(latlng);
}
};
let addMarker = function(marker) {
markers.push(marker);
if(markers.length>2) {
markers[markers.length-3].setMap(null);
if(lines.length>0) {
lines[lines.length-1].setMap(null);
}
}
};
let addLine = function(path) {
lines.push(path);
lines[lines.length-1].setMap(map);
};
let getLocations = function() {
return locations;
};
return {
addLocation: addLocation,
addMarker: addMarker,
addLine: addLine,
getLocations: getLocations
}
};