-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
43 lines (33 loc) · 1.6 KB
/
main.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
require.config({
paths: {
leaflet: "../bower_components/leaflet/dist/leaflet",
handlebars: "../bower_components/handlebars/handlebars.amd",
omnivore: "../bower_components/leaflet-omnivore/leaflet-omnivore",
}
});
require(["leaflet", "handlebars", "omnivore"], function(L, handlebars, omnivore){
"use strict";
// create a map in the "map" div, set the view to a given place and zoom
var map = L.map("map").setView([52.505, 10.09], 4);
// add an OpenStreetMap tile layer
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", {
attribution: "© <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors"
}).addTo(map);
var source = document.getElementById("popup-template").innerHTML;
var template = handlebars.compile(source);
var countriesLayer = L.geoJson(null, { style:
{
fillColor: "#d8c92d",
color: "#4cba6a"
}
}
).addTo(map);
var peopleLayer = L.geoJson(null, {
onEachFeature: function (feature, layer) {
var content = template(layer.feature.properties.data);
layer.bindPopup(content);
}
});
omnivore.topojson("./countries/codeforfreedom-countries.topojson", null, countriesLayer).addTo(map);
omnivore.geojson("./people/people.json", null, peopleLayer).addTo(map);
});