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
xxxxxxxxxx
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/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/leaflet@1.0.1/dist/leaflet-src.js"></script>
<script src="https://unpkg.com/leaflet-active-area@1.0.0/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="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
</script>
</body>
https://unpkg.com/leaflet@1.0.1/dist/leaflet-src.js
https://unpkg.com/leaflet-active-area@1.0.0/src/leaflet.activearea.js