forked from mapkibera/mapkibera.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.js
85 lines (73 loc) · 2.61 KB
/
site.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
---
---
;{% include js/jquery.min.js %}
;(function(context) {
var mapkibera = {}
mapkibera.global = function() {
function scroll(el){
$('html, body').animate({
scrollTop: $(el).offset().top
}, 500);
}
$('a[data-scroll]').click(function() {
var to = $(this).attr('href');
scroll(to);
return false;
});
};
mapkibera.slideShow = function(context) {
var slideIndex = 1,
$slide = $('[data-index]', context),
slides = $slide.length;
$('a.slide-control').click(function() {
$slide.removeClass('active');
if ($(this).hasClass('next')) {
if (slideIndex >= slides) {
slideIndex = 1;
} else {
slideIndex++;
}
} else {
if (slideIndex <= 1) {
slideIndex = slides;
} else {
slideIndex--;
}
}
$('[data-index="slide-' + slideIndex + '"]', context).addClass('active');
return false;
});
};
mapkibera.map = function(context) {
if (context.zoom_control == 'hide') {
var map = L.map(context.id, {zoomControl:false}).setView([parseFloat(context.lat), parseFloat(context.lon)], parseInt(context.zoom));
map.attributionControl.setPrefix(false);
} else {
var map = L.map(context.id).setView([parseFloat(context.lat), parseFloat(context.lon)], parseInt(context.zoom));
map.attributionControl.setPrefix(false).addAttribution("© <a href='http://openstreetmap.org'>OpenStreetMap</a> contributors, Map Kibera");
}
if (context.layer_control == 'show') {
//var layer_control = L.control.layers().addTo(map);
var layers = {};
}
var tileservers = context.tileserver.split(',');
for (var i=0; i< tileservers.length; i++) {
if (context.layer_control == 'show') {
layer_name_array = tileservers[i].split('/');
layer_name = layer_name_array[ layer_name_array.length -2 ];
layers[ layer_name ] = L.tileLayer(tileservers[i] + '{z}/{x}/{y}.png', { });
if (i == 0) {
layers[ layer_name ].addTo(map);
}
} else {
L.tileLayer(tileservers[i] + '{z}/{x}/{y}.png', {
}).addTo(map);
}
}
if (context.layer_control == 'show') {
L.control.layers(layers).addTo(map);
}
map.scrollWheelZoom.disable();
};
window.mapkibera = mapkibera;
})(window);