Last active
November 21, 2017 12:12
-
-
Save ivanmalagon/9526cbbf75c1f8f1e78e9079c763fee1 to your computer and use it in GitHub Desktop.
HaCkARTO.js boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>CARTO.js App</title> | |
<!-- Include Leaflet 1.2.0 Library --> | |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" /> | |
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script> | |
<!-- Include cartodb.js Library --> | |
<script src="https://rawgit.com/CartoDB/cartodb.js/dist/carto.js"></script> | |
<style> | |
html, body { margin: 0; padding: 0; } | |
#map { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
function main () { | |
// Create the Leaflet Map | |
var center = [40.4637, -3.7492]; | |
var zoomLevel = 4; | |
var map = L.map('map').setView(center, zoomLevel); | |
// Adding Voyager Basemap | |
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png', { | |
maxZoom: 18, | |
attribution: '©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, ©<a href="https://carto.com/attribution">CARTO</a>' | |
}).addTo(map); | |
// Adding Voyager Labels | |
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_only_labels/{z}/{x}/{y}.png', { | |
maxZoom: 18, | |
attribution: '©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, ©<a href="https://carto.com/attribution">CARTO</a>', | |
zIndex: 100 | |
}).addTo(map); | |
// From this point, it's all up to you | |
// Include the carto.js library and start creating a mapaza! | |
} | |
document.addEventListener('DOMContentLoaded', main); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment