Getting started with Leaflet
Built with blockbuilder.org
forked from enjalot's block: WWSD #1: Leaflet starter
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<link rel="stylesheet" href="https://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map('map').setView([30, 0], 2);
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var url = "https://enjalot.github.io/wwsd/data/world/ne_50m_admin_0_countries.geojson"
//fetch data from url and perform this function that returns an error or data
d3.json(url, function(err, data) {
L.geoJson(data, { style: { fillColor: "#111", weight: 1}}).addTo(map)
})
// var url = "https://enjalot.github.io/wwsd/data/world/ne_50m_populated_places_simple.geojson"
// //fetch data from url and perform this function that returns an error or data
// d3.json(url, function(err, data) {
// L.geoJson(data, { style: { fillColor: "#111", weight: 1}}).addTo(map)
// })
var url = "https://enjalot.github.io/wwsd/data/world/ne_50m_rivers_lake_centerlines.geojson"
//fetch data from url and perform this function that returns an error or data
d3.json(url, function(err, data) {
L.geoJson(data, { style: { fillColor: "#111", weight: 1}}).addTo(map)
})
</script>
</body>
Modified http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js to a secure url
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js
https://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js