forked from CodeForPhilly/philly-transit-map
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dom-ready.js
105 lines (78 loc) · 2.26 KB
/
dom-ready.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
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
// when the Doc/DOM is loaded
$(document).ready(function() {
var map = initialize(); // initialize the map
var container = $('.container');
// penndot camera info window hide/open
$("#markers a").bind("click", function(){
var i = $(this).attr("rel");
// close any open info windows
// $('#map_canvas').gmap('closeInfoWindow');
for(x=0; x < arrInfoWindows.length; x++){
arrInfoWindows[x].close(map, arrMarkers[x]);
alert(x);
}
arrInfoWindows[i].open(map, arrMarkers[i]);
});
// open sidebar
$('#toggle_sidebar').toggle(
function(){
container.addClass('open');
$("#map_canvas").css({height:$(".contents").height()}).css({width:$(".contents").width()});
},
// close sidebar
function(){
container.removeClass('open');
$("#map_canvas").css({height:$(".contents").height()}).css({width:$(".contents").width()});
});
$('.sidebar input').checked = false;
// changes to sidebar....ex: clicking checkboxes
// get values from html fields and assign to 'options'
$('.sidebar input').live("change", function(){
var options = {
feed: $(this).attr("data-layer-url"),
name: $(this).attr("data-layer-name"),
type: $(this).attr("data-layer-type")
};
// if a checkbox is checked....decide what to do based on 'type'
if (this.checked) {
// broken
if (options.type === "cameras") {
addPennDOTCameras(map);
}
// penndot cams
else if (options.type === "penndot") {
add_penndot(map);
}
// adds zipcar, pcs, penndot
else if (options.type === "points") {
addPointSet(options, map);
}
// add traffic
else if (options.type === "traffic") {
add_traffic(options, map);
}
// adds kml layers
else {
addLayer(options, map);
}
}
// checkbox unchecked....remove points or kml file
else {
if (options.name === "penndot-cameras") {
removePennDOTCameras(map);
}
else if (options.type === "penndot") {
remove_penndot(map);
}
else if (options.type === "points") {
removePointSet(options, map);
}
else if (options.type === "traffic") {
remove_traffic(options, map);
}
else {
removeLayer(options, map);
}
}
})
});