-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·124 lines (108 loc) · 4.08 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas {
width: 640px;
height: 640px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCGFXpg1qLpVIv72b8tTy-6xexMJWVI2Hk"></script>
<script src="./scripts/oms.min.js"></script>
<script>
function initialize() {
var mapCanvas = document.getElementById('map-canvas');
var mapOptions = {
center: new google.maps.LatLng(50.58, -126.95),
zoom: 4,
//mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions)
map.data.loadGeoJson('https://maps.dev4.catalogue.libraries.coop:4433/geojson/coop_geojson.json');
map.data.loadGeoJson('https://maps.dev4.catalogue.libraries.coop:4433/geojson/econ_region.json');
//does not load, no javascript error, so hard to detect. Download takes a long time because
//it is 160MB, so the javascript may never execute on this file, hence no error.
//map.data.loadGeoJson('https://maps.dev4.catalogue.libraries.coop:4433/geojson/school_dist.json');
var oms = new OverlappingMarkerSpiderfier(map);
var infowindow = new google.maps.InfoWindow();
var book_count = 0;
var current_library = '';
var old_library = '';
map.data.addListener('addfeature', function (e) {
if (e.feature.getGeometry().getType() === 'Point') {
old_library = current_library;
current_library = e.feature.getProperty('library_name0');
if (current_library == old_library) {
book_count++;
} else {
book_count = 0;
}
if (book_count < 8) {
var marker = new google.maps.Marker({
position: e.feature.getGeometry().get(),
title: e.feature.getProperty('title0'),
map: map
});
//We are displaying this marker, so set it's
//zIndex high so it receives clicks
marker.setZIndex(100000);
var text = '';
e.feature.forEachProperty(function (data, key) {
key = key.replace(/[0-9][0-9]*/, '');
key = key.charAt(0).toUpperCase() + key.slice(1);
text += '<strong>' + key + ':</strong> ' + data + "<br\>";
});
marker.desc = text;
oms.addMarker(marker);
oms.addListener('click', function(marker, event) {
infowindow.setContent(marker.desc);
infowindow.open(map, marker);
});
oms.addListener('spiderfy', function(markers) {
infowindow.close();
});
}
} else {
var color;
switch (e.feature.getProperty('OBJECTID')) {
case 9:
color = 'red';
break;
case 10:
color = 'yellow';
break;
case 11:
color = 'orange';
break;
case 12:
color = 'green';
break;
case 13:
color = 'purple';
break;
case 14:
color = 'brown';
break;
case 15:
color = 'white';
break;
case 16:
color = 'blue';
break;
default:
color = 'blue';
}
map.data.overrideStyle(e.feature, {fillColor: color});
/*e.feature.forEachProperty(function (data, key) {
alert(key + ': ' + data);
});*/
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>