Skip to content

Instantly share code, notes, and snippets.

Created December 22, 2012 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4357310 to your computer and use it in GitHub Desktop.
Save anonymous/4357310 to your computer and use it in GitHub Desktop.
currently non-functional cartodb MAP API call into leaflet switcher
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Switching + CartoDB</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="http://geosprocket.com/assets/leaflet/dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="http://geosprocket.com/assets/leaflet/dist/leaflet.ie.css" /><![endif]-->
<!--<script src="http://geosprocket.com/assets/leaflet/dist/leaflet.js"></script>-->
<script src="http://libs.cartocdn.com/cartodb.js/v2/cartodb.js"></script>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var night = L.tileLayer('http://a.tiles.mapbox.com/v3/landplanner.map-sa4pz9ny/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
}),
sat = L.tileLayer('http://a.tiles.mapbox.com/v3/landplanner.map-a0wbwf43/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
}),
ref = L.tileLayer('http://a.tiles.mapbox.com/v3/landplanner.map-6loa9k8g/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: 'Map data &copy; 2012 <a href="http://nasa.gov">NASA</a>'
}),
//Not currently the correct call.
communes = L.tileLayer({
version: '1.0.0',
scheme: 'xyz',
tiles: ['http://dai.cartodb.com/tiles/ag_2011_commune3/{z}/{x}/{y}.png'],
grids: ['http://dai.cartodb.com/tiles/ag_2011_commune3/{z}/{x}/{y}.grid.json']
});
var map = L.map('map', {
zoomControl: true,
center: [34.88593094075317, -3.0322265625],
zoom: 8,
layers: [night, sat, ref]
});
var baseLayers = {
"Night View": night,
"Satellite View": sat
};
var overlays = {
"Reference": ref,
"Communes" : communes
};
L.control.layers(baseLayers, overlays).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment