1 function createMap(divName, jsonFile) {
3 var map = L.map(divName);
5 // Add OpenStreetMap layer
6 L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
7 attribution: "© <a target=\"_parent\" href=\"http://www.openstreetmap.org\">OpenStreetMap</a> and contributors, under an <a target=\"_parent\" href=\"http://www.openstreetmap.org/copyright\">open license</a>",
11 // Add the JSON file as an overlay
14 success: function(json) {
15 var jsonLayer = L.geoJson(json, {
16 style: function(feature) {
17 return { color: feature.properties.colour, weight: 2, opacity: 1 }
19 onEachFeature: function (feature, layer) {
20 layer.bindPopup(feature.properties.country + " via " + feature.properties.server);
21 layer.on("mouseover", function () {
22 this.setStyle({ weight: 5 });
24 layer.on("mouseout", function () {
25 this.setStyle({ weight: 2 });
30 map.fitBounds(jsonLayer.getBounds());