-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeolocative.html
163 lines (98 loc) · 4.27 KB
/
geolocative.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Geolocative map</title>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
// CODE EXAMPLE FOR A GEOLOCATIVE APP WITH GOOGLE MAPS.
// READ MORE AT:
// https://developers.google.com/maps/documentation
// http://www.w3schools.com/html/html5_geolocation.asp
// Public variables
var map, userMarker, watchGPS;
// Function that draws the map and overlays custom data.
function initialise() {
$("#map-canvas").css('width','100%');
$("#map-canvas").css('height','500px');
map = new google.maps.Map(document.getElementById('map-canvas'));
// Replace the URL with the URL of your own google map.
// Right-click the KML symbol and copy the URL.
var kmlLayer = new google.maps.KmlLayer('https://maps.google.com/maps/ms?authuser=0&vps=2&hl=en&ie=UTF8&msa=0&output=kml&msid=212315989492493347029.0004d63d9ae018c583134', {suppressInfoWindows: false});
kmlLayer.setMap(map);
// Create custom icon showing the location of the user
userMarker = new google.maps.Marker({
map: map,
title:"You are here!"
});
userMarker.setIcon("https://chart.googleapis.com/chart?chst=d_map_pin_icon&chld=glyphish_walk|FBA");
// Call function that attempts to find user's location
getLocation ();
}
// Function that retrieves user's initial location and
// then continues to track their position on the map.
// Users must agree to share their position.
function getLocation() {
if (navigator.geolocation)
{
// Attempt to track user's position.
watchGPS = navigator.geolocation.watchPosition(function (position) {
// Store the reading of the longitude and latitute
var userLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
// Update the user map marker
userMarker.setPosition (userLocation);
});
}
else {
alert("Geolocation is not supported by this browser.");
}
}
// Trigger the map initialation function above
$( "#map" ).live ( "pageshow", function( event ) {
initialise();
});
</script>
</head>
<body>
<div data-role="page" id="front">
<div data-role="header">
<h1 id="make">Geolocative app</h1>
</div>
<div data-role="content">
<a href="#about" data-role="button">About the app</a>
<a href="#map" data-role="button">Open the map</a>
</div>
<div data-role="footer">
<h1>© 2014</h1>
</div>
</div>
<div data-role="page" id="about">
<div data-role="header">
<h1 id="make">About</h1>
</div>
<div data-role="content">
<h1>About app</h1>
<p>About text</p>
<a href="#" data-rel="back" data-role="button">Back</a>
</div>
<div data-role="footer">
<h1>© 2013</h1>
</div>
</div>
<div data-role="page" id="map">
<div data-role="header">
<h1 id="make">Explore map</h1>
</div>
<div data-role="content">
<div id="map-canvas" style="width: 100%; height: 500px;"></div>
<a href="#" data-rel="back" data-role="button">Back</a>
</div>
<div data-role="footer">
<h1>© 2013</h1>
</div>
</div>
</body>
</html>