mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-07 03:33:39 +02:00
Add and style category filter
This commit is contained in:
parent
41d831b542
commit
a30ad1fc1c
3 changed files with 85 additions and 11 deletions
|
|
@ -1,6 +1,9 @@
|
|||
(function () {
|
||||
"use strict";
|
||||
|
||||
// http://www.colourlovers.com/palette/1811244/1001_Stories
|
||||
var colors = [ '#F8B195', '#F67280', '#C06C84', '#6C5B7B', '#355C7D' ];
|
||||
|
||||
// set up background map
|
||||
var map = L.map('map').setView([52.50, 13.40], 11);
|
||||
var layer = new L.StamenTileLayer('toner-lite');
|
||||
|
|
@ -20,15 +23,23 @@
|
|||
// logic for drawing follows
|
||||
|
||||
var markers = [];
|
||||
function createMarker (data) {
|
||||
var options = { color: pickColor(data) };
|
||||
var marker = L.circleMarker([data.lat, data.lng], options).addTo(map);
|
||||
return marker;
|
||||
}
|
||||
|
||||
function pickColor (data) {
|
||||
var categories = [ 'racism', 'antisemitism', 'sexism', 'homophobia' ];
|
||||
return data.categories.length ? colors[categories.indexOf(data.categories[0])] : colors[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all incidents at once
|
||||
*/
|
||||
function displayAll () {
|
||||
for (var i = 0, l = response.length; i < l; i++) {
|
||||
markers.push(
|
||||
L.marker([response[i].lat, response[i].lng]).addTo(map).bindPopup(response[i].description)
|
||||
)
|
||||
markers.push(createMarker(response[i]).bindPopup(response[i].description));
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue