Demonstrates loading data from a Carto table and creating a GeoJSON vector layer in a Leaflet Map.
Built with blockbuilder.org
forked from clhenrick's block: Leaflet with a Carto Layer I
license: mit |
Demonstrates loading data from a Carto table and creating a GeoJSON vector layer in a Leaflet Map.
Built with blockbuilder.org
forked from clhenrick's block: Leaflet with a Carto Layer I
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
#map { | |
height: 100%; | |
} | |
div.active-area, | |
.viewport { | |
position: absolute; | |
top: 50px; | |
right: 50px; | |
left: 300px; | |
height: 400px; | |
border: 2px solid black; | |
z-index: 1000; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<div class="active-area"></div> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet-src.js"></script> | |
<script src="https://unpkg.com/[email protected]/src/leaflet.activearea.js"></script> | |
<script> | |
var Paris = [48.85346, 2.34956], | |
London = [51.505, -0.09], | |
popupOptions = { | |
autoPan: true, | |
keepInView: true | |
}; | |
var map = new L.Map('map', { inertia: false }) | |
.setActiveArea('active-area') | |
.setView(Paris, 13); | |
L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png', { | |
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' | |
}).addTo(map); | |
</script> | |
</body> |