-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgoogle.maps.js
More file actions
81 lines (74 loc) · 2.37 KB
/
google.maps.js
File metadata and controls
81 lines (74 loc) · 2.37 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(function (Remotes) {
var arrowUp, arrowRight, arrowDown, arrowLeft, zoomIn, zoomOut, i;
var divs = document.getElementsByTagName('div');
for (i = 0; i < divs.length; i++) {
switch (divs[i].getAttribute("log")) {
case "pan_up":
arrowUp = divs[i];
break;
case "pan_rt": arrowRight = divs[i]; break;
case "pan_down": arrowDown = divs[i]; break;
case "pan_lt": arrowLeft = divs[i]; break;
default: break;
}
switch (divs[i].getAttribute("guidedhelpid")) {
case "zoom_in": zoomIn = divs[i].children[1]; break;
case "zoom_out": zoomOut = divs[i].children[1]; break;
default: break;
}
}
function activateElement(element) {
var myEvent;
if (document.createEventObject) {
myEvent = document.createEventObject();
return element.fireEvent('onclick', myEvent);
} else {
myEvent = document.createEvent("HTMLEvents");
myEvent.initEvent('click', true, true);
return !element.dispatchEvent(myEvent);
}
}
function toggleSatellite() {
var satellite, maps;
for (i = 0; i < divs.length; i++) {
if (divs[i].getAttribute("jsprops") === "activityId:4") {
maps = divs[i];
} else if (divs[i].getAttribute("jsprops") === "activityId:3") {
satellite = divs[i];
}
}
if (maps) {
activateElement(maps);
} else {
activateElement(satellite);
}
}
function toggleOverlayedInfo() {
console.log('hold');
var satellite, maps, traffic, labels;
for (i = 0; i < divs.length; i++) {
if (divs[i].getAttribute("jsprops")=="activityId:4") {
maps = divs[i];
} else if (divs[i].getAttribute("jsprops")=="activityId:3") {
satellite = divs[i];
} else if (divs[i].getAttribute("jsprops") == "activityId:7") {
traffic = divs[i];
} else if (divs[i].getAttribute("jsprops") == "activityId:1") {
labels = divs[i];
}
}
if (maps) {
activateElement(labels);
} else if (maps) {
activateElement(traffic);
}
}
Remotes.on("swipe-up", function(e) { activateElement(arrowUp); })
.on("swipe-right", function(e) { activateElement(arrowLeft); })
.on("swipe-down", function(e) { activateElement(arrowDown); })
.on("swipe-left", function(e) { activateElement(arrowRight); })
.on("zoom-in", function(e) { activateElement(zoomIn); })
.on("zoom-out", function(e) { activateElement(zoomOut); })
.on("tap", function(e) { toggleSatellite(); })
.on("hold", function(e) { toggleOverlayedInfo(); });
})(new Remotes("preview"));