cartodb/lib/assets/javascripts/cdb/examples/leaflet_namedmap.html

64 lines
1.5 KiB
HTML
Raw Normal View History

2020-06-15 10:58:47 +08:00
<!DOCTYPE html>
<html>
<head>
<title>Leaflet multilayer example | CartoDB.js</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="http://libs.cartodb.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://libs.cartodb.com/cartodb.js/v3/3.15/cartodb.js"></script>
<script>
function main() {
// create leaflet map
var map = L.map('map', {
zoomControl: false,
center: [43, 0],
zoom: 3
})
// add a base layer
L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
attribution: 'Stamen'
}).addTo(map);
// add cartodb layer with one sublayer
cartodb.createLayer(map, {
type: 'namedmap',
user_name: 'documentation',
options: {
named_map: {
name: 'tpl_b47ff8ec_e7eb_11e3_894f_0e230854a1cb'
}
}
})
.addTo(map)
.done(function(layer) {
});
}
// you could use $(window).load(main);
window.onload = main;
</script>
</body>
</html>