Skip to content

Commit 480b307

Browse files
committed
Use topojson instead of geojson
1 parent c0aa689 commit 480b307

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"tests"
1515
],
1616
"dependencies": {
17-
"jquery": "~2.1.4"
17+
"jquery": "~2.1.4",
18+
"leaflet-omnivore": "~0.3.2"
1819
}
1920
}

countries/codeforfreedom-countries.topojson

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

js/main.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ require.config({
22
paths: {
33
leaflet: "/bower_components/leaflet/dist/leaflet",
44
handlebars: "/bower_components/handlebars/handlebars.amd",
5-
jquery: "/bower_components/jquery/dist/jquery.min"
5+
jquery: "/bower_components/jquery/dist/jquery.min",
6+
omnivore: "/bower_components/leaflet-omnivore/leaflet-omnivore",
67
}
78
});
89

910

10-
require(["leaflet", "handlebars", "jquery"], function(L, handlebars, $){
11+
require(["leaflet", "handlebars", "jquery", "omnivore"], function(L, handlebars, $, omnivore){
1112
"use strict";
1213
// create a map in the "map" div, set the view to a given place and zoom
1314
var map = L.map("map").setView([52.505, 10.09], 4);
@@ -18,17 +19,15 @@ require(["leaflet", "handlebars", "jquery"], function(L, handlebars, $){
1819
}).addTo(map);
1920

2021

21-
// Selected countries
22-
var countries;
23-
$.getJSON("countries/codeforfreedom-countries.geojson", function(data) {
24-
countries = data;
25-
})
26-
.done(function(){
27-
L.geoJson(countries, { style: {
28-
fillColor: "#d8c92d",
29-
color: "#4cba6a"
30-
}}).addTo(map);
31-
});
22+
var countriesLayer = L.geoJson(null, { style:
23+
{
24+
fillColor: "#d8c92d",
25+
color: "#4cba6a"
26+
}
27+
}
28+
).addTo(map);
29+
30+
omnivore.topojson("/countries/codeforfreedom-countries.topojson", null, countriesLayer).addTo(map);
3231

3332

3433
// People from everywhere
@@ -41,7 +40,7 @@ require(["leaflet", "handlebars", "jquery"], function(L, handlebars, $){
4140
});
4241

4342
var mappedPeople = [];
44-
var source = $("#popup-template").html();
43+
var source = document.getElementById("popup-template").innerHTML;
4544
var template = handlebars.compile(source);
4645

4746
function addPeople(data){

0 commit comments

Comments
 (0)