-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaps.html
101 lines (71 loc) · 2.38 KB
/
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Single page template</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="libs/jquery.ui.map.full.min.js" type="text/javascript"></script>
<script type="text/javascript">
var gm = null;
$(document).bind('pageinit', function() {
initiate_geolocation();
});
function initiate_geolocation() {
navigator.geolocation.getCurrentPosition(initializeMap);
}
function initializeMap(position) {
console.log('Lat: ' + position.coords.latitude + ' ' +
'Lon: ' + position.coords.longitude);
var myCenter = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var myMarker = new google.maps.Marker({
position:myCenter,
bounds: true,
animation:google.maps.Animation.BOUNCE
});
var mapProp = {
center: myCenter,
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
gm = $('#content-primary');
gm.gmap(mapProp);
gm.gmap('addMarker', myMarker);
addMarkers();
}
function addMarkers() {
// Check if map loaded
if (gm === null) {
return;
}
$.getJSON( '/rest/hosting/people.json', function(data) {
$.each( data, function(i, m) {
gm.gmap('addMarker', { position: new google.maps.LatLng(m.latitude, m.longitude), bounds:true } )
.click(function() {
gm.gmap('openInfoWindow', { 'content': getPersonInfoHtml(m)}, this);
});
});
});
}
function getPersonInfoHtml(person) {
return '<h3>'+person.name+'</h3>Phone: <a href="tel:'+person.cellNumber+'">'+person.cellNumber+'</a>';
}
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Single page</h1>
</div><!-- /header -->
<div data-role="content">
<div id="content-primary" style="width:550px;height:550px"></div>
</div><!-- /content -->
<div data-role="footer">
<h4>Footer content</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>