-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathconfetti.js
More file actions
337 lines (312 loc) · 7.49 KB
/
confetti.js
File metadata and controls
337 lines (312 loc) · 7.49 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
var debug = {};
var map = L.map('map').setView([21, 80], 5); // India
L.tileLayer('http://{s}.tiles.mapbox.com/v3/spatialdev.map-c9z2cyef/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'examples.map-i86knfo3'
}).addTo(map);
var pbfSource = new L.TileLayer.MVTSource({
url: "http://spatialserver.spatialdev.com/services/postgis/cicos_2014/geom/vector-tiles/{z}/{x}/{y}.pbf?fields=type,id",
debug: false,
clickableLayers: null,
getIDForLayerFeature: function(feature) {
return feature.properties.id;
},
/**
* The filter function gets called when iterating though each vector tile feature (vtf). You have access
* to every property associated with a given feature (the feature, and the layer). You can also filter
* based of the context (each tile that the feature is drawn onto).
*
* Returning false skips over the feature and it is not drawn.
*
* @param feature
* @returns {boolean}
*/
filter: function(feature, context) {
//return feature.properties.type != 'Mobile Money Agent';
return true;
},
/**
* When we want to link events between layers, like clicking on a label and a
* corresponding polygon freature, this will return the corresponding mapping
* between layers. This provides knowledge of which other feature a given feature
* is linked to.
*
* @param layerName the layer we want to know the linked layer from
* @returns {string} returns corresponding linked layer
*/
layerLink: function(layerName) {
if (layerName.indexOf('_label') > -1) {
return layerName.replace('_label', '');
}
return layerName + '_label';
},
/**
* Specify which features should have a certain z index (integer). Lower numbers will draw on 'the bottom'.
*
* @param feature - the PBFFeature that contains properties
*/
layerOrdering: function(feature) {
//This only needs to be done for each type, not necessarily for each feature. But we'll start here.
if (feature && feature.properties) {
feature.properties.zIndex = CICO_LAYERS[feature.properties.type].zIndex || 5;
}
},
style: function(feature) {
var style = {};
var selected = style.selected = {};
var pointRadius = 1;
function ScaleDependentPointRadius(zoom) {
//Set point radius based on zoom
var pointRadius = 1;
if (zoom >= 0 && zoom <= 7) {
pointRadius = 1;
}
else if (zoom > 7 && zoom <= 10) {
pointRadius = 2;
}
else if (zoom > 10) {
pointRadius = 3;
}
return pointRadius;
}
var type = feature.type;
switch (type) {
case 1: //'Point'
// unselected
style.color = CICO_LAYERS[feature.properties.type].color || '#3086AB';
style.radius = ScaleDependentPointRadius;
// selected
style.selected = {
color: 'rgba(255,255,0,0.5)',
radius: 6
};
break;
case 2: //'LineString'
// unselected
style.color = 'rgba(161,217,155,0.8)';
style.size = 3;
// selected
style.selected = {
color: 'rgba(255,255,0,0.5)',
size: 6
};
break;
case 3: //'Polygon'
// unselected
style.color = 'rgba(149,139,255,0.4)';
style.outline = {
color: 'rgb(20,20,20)',
size: 2
};
// selected
style.selected = {
color: 'rgba(255,255,0,0.5)',
outline: {
color: '#d9534f',
size: 3
}
};
}
return style;
},
onClick: function(evt) {
console.log('clickkkk');
}
});
debug.mvtSource = pbfSource;
//Add layer
map.addLayer(pbfSource);
var CICO_LAYERS = {
'Offsite ATMs': {
color: '#3086AB',
infoLabel: 'Offsite ATM',
providers: null,
zIndex: 6
},
'Bank Branches': {
color: '#977C00',
infoLabel: 'Bank Branch',
providers: null,
zIndex: 5
},
'MFIs': {
color: '#9B242D',
infoLabel: 'MFI',
providers: null,
zIndex: 7
},
'SACCOs': {
color: '#cf8a57',
infoLabel: 'SACCO',
providers: null,
zIndex: 10
},
'Mobile Money Agent': {
color: '#8CB7C7',
infoLabel: 'Mobile Money Agent',
providers: null,
zIndex: -1
},
'MDIs': {
color: '#825D99',
infoLabel: 'MDI',
providers: null,
zIndex: 6
},
'Credit Institution': {
color: '#6CA76B',
infoLabel: 'Credit Institution',
providers: null,
zIndex: 5
},
'MFBs': {
color: '#825D99',
infoLabel: 'MFB',
providers: null,
zIndex: 7
},
'Motor Parks': {
color: '#bd85b3',
infoLabel: 'Motor Parks',
providers: null,
zIndex: 7
},
'Mobile Network Operator Outlets': {
color: '#a2a2a2',
infoLabel: 'Mobile Network Operator Outlets',
providers: null,
zIndex: 0
},
'Post Offices': {
color: '#FFFF00',
infoLabel: 'Post Offices',
providers: null,
zIndex: 4
},
'Post Office': {
color: '#80ad7b',
infoLabel: 'Post Offices',
providers: null,
zIndex: 6
},
'Bus Stand': {
color: '#80ad7b',
infoLabel: 'Bus Stands',
providers: null,
zIndex: 6
},
'Bus Stands': {
color: '#80ad7b',
infoLabel: 'Bus Stands',
providers: null,
zIndex: 6
},
//Kenya
'Insurance Providers': {
color: '#3086AB',
infoLabel: 'Insurance providers',
providers: null,
zIndex: 6
},
'Money Transfer Service': {
color: '#977C00',
infoLabel: 'Money Transfer Service',
providers: null,
zIndex: 6
},
'Dev Finance': {
color: '#9B242D',
infoLabel: 'Dev Finance',
providers: null,
zIndex: 6
},
'Forex Bureaus': {
color: '#cf8a57',
infoLabel: 'Forex Bureaus',
providers: null,
zIndex: 6
},
'Cap Markets': {
color: '#825D99',
infoLabel: 'Cap Markets',
providers: null,
zIndex: 6
},
'Pension Providers': {
color: '#a2a2a2',
infoLabel: 'Pension providers',
providers: null,
zIndex: 6
},
'Purchase Lease Factoring': {
color: '#80ad7b',
infoLabel: 'Purchase Lease Factoring',
providers: null,
zIndex: 6
},
'Bank Agent': {
color: '#80ad7b',
infoLabel: 'Bank Agent',
providers: null,
zIndex: 6
},
'Bank and Mortgage': {
color: '#80ad7b',
infoLabel: 'Banks and Mortgage',
providers: null,
zIndex: 6
},
'Commercial Bank': {
color: '#80ad7b',
infoLabel: 'Commercial Bank',
providers: null,
zIndex: 3
},
'PostBank': {
color: '#bd85b3',
infoLabel: 'Post Bank',
providers: null,
zIndex: 6
},
//Nigeria New Post Offices
'NIPOST Post Office': {
color: '#80ad7b',
infoLabel: 'NIPOST Post Offices',
providers: null,
zIndex: 6
},
'NIPOST Post Shop': {
color: '#80ad7b',
infoLabel: 'NIPOST Post Shops',
providers: null,
zIndex: 6
},
'NIPOST Postal Agency': {
color: '#80ad7b',
infoLabel: 'NIPOST Postal Agencies',
providers: null,
zIndex: 6
},
//India
'Postal Outlets': {
color: '#E6DC00',
infoLabel: 'Postal Outlets',
providers: null,
zIndex: 3
},
'Commercial Banks': {
color: '#80ad7b',
infoLabel: 'Commercial Banks',
providers: null,
zIndex: 2
},
'Bank Customer Service Points': {
color: '#977C00',
infoLabel: 'Bank Customer Service Points',
providers: null,
zIndex: 4
}
};