-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmap.html
More file actions
103 lines (81 loc) · 2.61 KB
/
map.html
File metadata and controls
103 lines (81 loc) · 2.61 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>External Map</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script>
/*
function findMyCurrentLocation(){
var geoService = navigator.geolocation;
if (geoService) {
console.log("GEO SERVICE")
navigator.geolocation.getCurrentPosition(showCurrentLocation,errorHandler,{enableHighAccuracy:true});
} else {
alert("Your Browser does not support GeoLocation.");
}
}
*/
google.maps.visualRefresh = true;
var map;
function initialize() {
console.log("initialize")
//Create the latlng object based on the GPS Position retrieved
var latlng = new google.maps.LatLng (37.77218900879787,-122.4064996013827);
//Set Google Map options
var mapOptions = {
zoom : 14,
center : latlng,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
var $content = $("#map-page");
//Set the height of the div containing the Map to rest of the screen
$content.height(screen.height - 50);
//Display the Map
map = new google.maps.Map ($content[0], mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
window.addEventListener('message', receiveMessage, false);
infowindow = new google.maps.InfoWindow();
messageArray = new Array();
photoArray = new Array();
function receiveMessage(event) {
//console.log(event.data);
photos = JSON.parse(event.data);
for (var i = 0; i < photos.length; i++) {
zIndex = i + 1;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(photos[i]["location"]["lat"], photos[i]["location"]["lon"]),
map: map,
title: photos[i]["title"],
zIndex: zIndex
});
attachMessage(marker, i, photos[i]["title"], photos[i]["photo"]);
}
//Create the Marker and Drop It
new google.maps.Marker ({ map : map,
animation : google.maps.Animation.DROP,
position : latlng
});
}
function attachMessage(marker, num, title,photo) {
messageArray.push(title);
photoArray.push(photo);
var content ="<img height='100px' src='"+ photoArray[num] +"'><br/>" + messageArray[num];
var infowindow = new google.maps.InfoWindow({
content: content
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(marker.get('map'), marker);
});
}
</script>
</head>
<body>
<div id="map-canvas"></div>
<div id="map-page" ></div>
</body>
</html>