-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
61 lines (54 loc) · 1.98 KB
/
map.js
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
/**
* Ottawa Livability Map
* @author Dave Schindler ([email protected])
*/
(function(olm) {
olm.map = {};
olm.groceryLayer = {};
olm.placesLayer = {};
olm.schoolLayer = {};
olm.transitLayer = {};
olm.wardsLayer = {};
olm.initialize = function() {
var mapOptions = {
mapTypeId: google.maps.MapTypeId.TERRAIN
};
olm.map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
olm.wardsLayer = new google.maps.KmlLayer({
url: 'https://github.com/schindld/ottawa-livability/raw/master/data/wards-data.kml'
});
olm.groceryLayer = new google.maps.KmlLayer({
url: 'https://github.com/schindld/ottawa-livability/raw/master/data/grocery-data.kml'
});
olm.placesLayer = new google.maps.KmlLayer({
url: 'https://github.com/schindld/ottawa-livability/raw/master/data/places-data.kml'
});
olm.schoolLayer = new google.maps.KmlLayer({
url: 'https://github.com/schindld/ottawa-livability/raw/master/data/school-data.kml'
});
olm.transitLayer = new google.maps.KmlLayer({
url: 'https://github.com/schindld/ottawa-livability/raw/master/data/transit-data.kml'
});
//olm.wardsLayer.setMap(olm.map);
//olm.groceryLayer.setMap(olm.map);
olm.placesLayer.setMap(olm.map);
olm.schoolLayer.setMap(olm.map);
//olm.transitLayer.setMap(olm.map);
google.maps.event.addListenerOnce(olm.map, 'tilesloaded', olm.onKmlLoad);
}
olm.onKmlLoad = function() {
olm.wardsLayer.setOptions({'preserveViewport':true});
olm.groceryLayer.setOptions({'preserveViewport':true});
olm.placesLayer.setOptions({'preserveViewport':true});
olm.schoolLayer.setOptions({'preserveViewport':true});
olm.transitLayer.setOptions({'preserveViewport':true});
};
google.maps.event.addDomListener(window, 'load', olm.initialize);
olm.toggleLayer = function(layer) {
if (!layer.getMap()) {
layer.setMap(olm.map);
} else {
layer.setMap(null);
}
};
}(window.olm = window.olm || {}));