-
Notifications
You must be signed in to change notification settings - Fork 0
/
oms.html
131 lines (112 loc) · 3.88 KB
/
oms.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<title>Overlapping Marker Spiderfier demo</title>
<style>
html {
height: auto;
}
body {
height: auto;
margin: 0;
padding: 0;
font-family: Georgia, serif;
font-size: 0.9em;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
p {
margin: 0.75em 0;
}
#map_canvas {
height: auto;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
}
@media print {
#map_canvas {
height: 950px;
}
}
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
</style>
<script src="//maps.googleapis.com/maps/api/js?v=3"></script>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="js/oms.min.js"></script>
<script>
window.onload = function() {
var gm = google.maps;
var map = new gm.Map(document.getElementById('map_canvas'), {
mapTypeId: gm.MapTypeId.ROADMAP,
center: new gm.LatLng(35.104874, -106.627808), zoom: 10
});
var iw = new gm.InfoWindow();
var oms = new OverlappingMarkerSpiderfier(map,
{markersWontMove: true, markersWontHide: true});
var shadow = new gm.MarkerImage(
'https://www.google.com/intl/en_ALL/mapfiles/shadow50.png',
new gm.Size(37, 34), // size - for sprite clipping
new gm.Point(0, 0), // origin - ditto
new gm.Point(10, 34) // anchor - where to meet map location
);
oms.addListener('click', function(marker) {
iw.setContent(marker.desc);
iw.open(map, marker);
});
$.getJSON("php/locations.json", function(json1) {
$.each(json1, function(key, data) {
var loc = new gm.LatLng(data.lat, data.lng);
var iconImage;
switch (data.year) {
case '2013':
iconImage = 'img/purple.png';
break;
case '2012':
iconImage = 'img/blue.png';
break;
case '2011':
iconImage = 'img/yellow.png';
break;
case '2010':
iconImage = 'img/green.png';
break;
}
var marker = new gm.Marker({
position: loc,
title: data.year,
map: map,
shadow: shadow
});
marker.setIcon(iconImage);
marker.desc = '<div id="content">' +
'<h1>Accident Data</h1>' +
'<div id="bodyContent">' +
'<p>Latitude: ' + data.lat + ', Longitude: ' + data.lng + '</p>' +
'<table><tr><th>Year</th><th># of accidents at this location</th></tr>' +
'<tr><td>' + data.year + '</td><td style="text-align: center">' + data.accidentCount + '</td></tr>' +
'</table>' +
'<p></p>' +
'</div>' +
'</div>';
oms.addMarker(marker);
})
});
}
</script>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>