<title>A basic map with Leaflet</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
<div id="map-container"></div>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
let map = L.map('map-container');
map.setView([52.268, 4.998], 7);
let bglayer_Positron = L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="https://cartodb.com/attributions">CartoDB</a>',
bglayer_Positron.addTo(map);
//define color of points based on earthquake type
function colorPoints(type){
return type === 'tec' ? '#35495D' :
type === 'ind' ? '#EA9657' :
//define how our point data will be visualized
function styleEarthquakePoints(feature){
radius: 2.5*Math.sqrt((Math.exp(parseFloat(feature.properties.MAG)))),
fillColor: colorPoints(feature.properties.TYPE),
//create an empty geojson layer that already knows how to style the data
var geojson = L.geoJson(null,{
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, styleEarthquakePoints(feature));
//define a function to get and parse geojson from URL
async function getGeoData(url) {
let response = await fetch(url);
let data = await response.json();
//fetch the geojson and add it to our geojson layer
getGeoData('aardbevingen_NL.geojson').then(data => geojson.addData(data));