-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample.js
157 lines (138 loc) · 4.55 KB
/
sample.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//MAP SCRIPT
var mapt9b;
var type = 1,loaded=1;
var sub,s92,s94,s96,s98,s00,s02,s04,s06,s08,s10,s12;
var year_ = 1990;
(function($) {
function formatNumber (num) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
}
$(function() {
var mapbounds;
//CREATE MAP AND ADD BASEMAP LAYER for T1-T2-B
mapt9b = L.map('map', {
center: [37.7833, -122.4167],
zoom: 12,
minZoom: 8,
fullscreenControl: true
});
// Set map bounds for the reload map button
mapbounds = mapt9b.getBounds();
// Add the base tile layer
L.mapbox.accessToken = 'pk.eyJ1IjoicG9zdGNvZGUiLCJhIjoiWWdxRTB1TSJ9.phHjulna79QwlU-0FejOmw';
var basemap = L.mapbox.tileLayer('postcode.kh28fdpk').addTo(mapt9b);
L.control.scale().addTo(mapt9b);
// Add
sub = new L.TileLayer('http://gis.mtc.ca.gov/mtc/rest/services/VitalSigns/LU5_Greenfield_1990_Cache/MapServer/tile/{z}/{y}/{x}')
.addTo(mapt9b);
function clickUpdate(e) {
//console.log(e.target.feature.properties);
if(e.target.feature.properties.YEAR==1990){
$('.year_info').html("This area was developed before 1990.");
}else{
$('.year_info').html("This area was developed in "+e.target.feature.properties.YEAR+".");
}
}
//DEFINE SLIDER AND ASSOCIATED FUNCTIONS
var t9btimeslider = $("#t9btimeslider").kendoSlider({
increaseButtonTitle: "Right",
decreaseButtonTitle: "Left",
min: 1990,
max: 2012,
smallStep: 2,
largeStep: 2,
tickPlacement: "none",
change: sliderChanget9b,
slide: sliderChanget9b,
tooltip: {
enabled: false
}
}).data("kendoSlider");
var s92, s94, s96, s98, s00, s02, s04, s06, s08, s10, s12;
function sliderChanget9b(e) {
//console.log(e.value);
var val =t9btimeslider.value();
$('.year').html(val);
if(val ==1990){
if(year_>val && s92) {
mapt9b.removeLayer(s92);
}
}
if(val ==1992){
if(year_>val && s94) {
mapt9b.removeLayer(s94);
}else{
cartodb.createLayer(map, 'http://localdata.cartodb.com/api/v2/viz/4a796c3c-c849-11e4-b0d5-0e018d66dc29/viz.json')
.addTo(map)
.on('done', function(layer) {
s92 = layer;
});
}
}
if(val ==1994){
if(year_>val && s96) {
mapt9b.removeLayer(s96);
}else{
cartodb.createLayer(map, 'http://localdata.cartodb.com/api/v2/viz/4a796c3c-c849-11e4-b0d5-0e018d66dc29/viz.json')
.addTo(map)
.on('done', function(layer) {
s96 = layer;
});
}
}
if(val ==1996){
if(year_>val && s98) {
mapt9b.removeLayer(s98);
}else{
// etc etc
}
}
if(val ==1998){
if(year_>val) {
mapt9b.removeLayer(s00);
}else{
}
}
if(val ==2000){
if(year_>val) {
mapt9b.removeLayer(s02);
}else{
}
}
if(val ==2002){
if(year_>val) {
mapt9b.removeLayer(s04);
}else{
}
}
if(val ==2004){
if(year_>val) {
mapt9b.removeLayer(s06);
}else{
}
}
if(val ==2006){
if(year_>val) {
mapt9b.removeLayer(s08);
}else{
}
}
if(val ==2008){
if(year_>val) {
mapt9b.removeLayer(s10);
}else{
}
}
if(val ==2010){
if(year_>val) {
mapt9b.removeLayer(s12);
}else{
}
}
if(val ==2012){
s96.addTo(mapt9b);
}
year_=val;
}
});
})(jQuery);