-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathapp-FlipViewApp-Maps.html
126 lines (109 loc) · 4.53 KB
/
app-FlipViewApp-Maps.html
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<head>
<title>Maps</title>
<!--
Google Maps app created using FlipView App template
-->
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" />
<link rel="stylesheet" type="text/css" href="appframework/af.ui.css" />
<link rel="stylesheet" type="text/css" href="appframework/icons.css" />
<script type="text/javascript" charset="utf-8" src="appframework/appframework.ui.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<!-- Required if building app using Intel XDK -->
<script src="intelxdk.js"></script>
<script src="xhr.js"></script>
<script>
$.ui.autoLaunch = false;
$.ui.animateHeaders = false;
/* Required if building app using Intel XDK */
function onDeviceReady(){
$.ui.launch();
intel.xdk.device.hideSplashScreen();
}
$(document).ready(function(){
document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);
$.ui.launch();
setupMap();
});
/* Google Maps API code to show map and layers */
var map;
function setupMap(){
var mapOptions = {
center: new google.maps.LatLng(45.53, -122.67),
zoom: 10,
mapTypeControl: false,
streetViewControl: false,
navigationControl: true,
scrollwheel: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map"), mapOptions);
}
function getGeoLocation(){
var success = function(position){
map.panTo(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
}
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, null);
}
}
var trafficLayer = new google.maps.TrafficLayer();
var transitLayer = new google.maps.TransitLayer();
var bicyclingLayer = new google.maps.BicyclingLayer();
function toggleTrafficLayer(){
document.getElementById('toggle1').checked ? trafficLayer.setMap(map) : trafficLayer.setMap(null);
}
function toggleTransitLayer(){
document.getElementById('toggle2').checked ? transitLayer.setMap(map) : transitLayer.setMap(null);
}
function toggleBicyclingLayer(){
document.getElementById('toggle3').checked ? bicyclingLayer.setMap(map) : bicyclingLayer.setMap(null);
}
</script>
<style>
body, #afui {background-color:#000}
#afui #settingsList.list li {padding: 10px}
#map {position:absolute;top:0;bottom:-10px;left:-10px;right:-10px}
</style>
</head>
<body>
<div id="afui">
<div id="content" style="">
<div class="panel" title="Maps" id="mainpage" data-footer="none" selected="true">
<header>
<h1>Maps</h1>
<a href="#" class="button icon target" onclick="getGeoLocation()"></a>
<a href="#backpage" data-transition="flip" class="button icon settings" style="float:right"></a>
</header>
<div id="map"></div>
</div>
<div class="panel" title="Settings" id="backpage" data-footer="none">
<header>
<h1>Settings</h1>
<a onclick="$.ui.goBack();" data-transition="flip" class="button icon close" style="float:right"></a>
</header>
<p></p>
<ul class="list inset" id="settingsList">
<li>
<label>Traffic</label>
<input id="toggle1" type="checkbox" name="toggle1" value="0" class="toggle" onchange="toggleTrafficLayer()">
<label style="left:70%" for="toggle1" data-on="On" data-off="Off"><span></span></label>
</li>
<li>
<label>Transit</label>
<input id="toggle2" type="checkbox" name="toggle2" value="0" class="toggle" onchange="toggleTransitLayer()">
<label style="left:70%" for="toggle2" data-on="On" data-off="Off"><span></span></label>
</li>
<li>
<label>Bicycling</label>
<input id="toggle3" type="checkbox" name="toggle3" value="0" class="toggle" onchange="toggleBicyclingLayer()">
<label style="left:70%" for="toggle3" data-on="On" data-off="Off"><span></span></label>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>