This is an example of automatic raster reprojection of a tiled layer from d3.carto.map.
It still needs some work. It does not reproject the raster on-the-fly but rather only reprojects it at "zoomend" which is triggered at the end of a zoom or pan event.
This uses Jason Davies' d3.geo.raster and d3.quadtiles.
xxxxxxxxxx
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>d3.carto.map - Reprojected Tiles</title>
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" href="d3map.css" />
<link type="text/css" rel="stylesheet" href="example.css" />
</head>
<style>
html,body {
height: 100%;
width: 100%;
margin: 0;
}
#map {
height: 100%;
width: 100%;
position: absolute;
}
button.reproject {
position: fixed;
z-index: 1;
top: 250px;
}
</style>
<script>
function makeSomeMaps() {
map = d3.carto.map();
d3.select("#map").call(map);
map.mode("projection")
tileLayer = d3.carto.layer.tile();
tileLayer
.path("examples.map-zgrqqx0w")
.label("Base");
geojsonLayer = d3.carto.layer.geojson();
geojsonLayer
.path("https://bl.ocks.org/emeeks/raw/c970c9ee3e242e90004b/world.geojson")
.label("GeoJSON Countries")
.cssClass("halffilledcountries")
.renderMode("svg");
topojsonLayer = d3.carto.layer.topojson();
topojsonLayer
.path("sample_routes.topojson")
.label("TopoJSON Lines")
.cssClass("roads")
.renderMode("svg");
csvLayer = d3.carto.layer.csv();
csvLayer
.path("sample_points.csv")
.label("CSV Points")
.cssClass("pinkcircle")
.renderMode("svg")
.x("x")
.y("y")
.markerSize(2);
map.addCartoLayer(tileLayer);
map.addCartoLayer(geojsonLayer);
map.addCartoLayer(topojsonLayer);
map.addCartoLayer(csvLayer);
d3.json("world.geojson", function(error,data) {
fNamedCountries = data.features.filter(function (d) {return d.properties.name.substring(0,1) == "F"});
featureLayer = d3.carto.layer.featureArray();
featureLayer
.features(fNamedCountries)
.label("Filtered Features")
.cssClass("francelike")
.renderMode("svg");
map.addCartoLayer(featureLayer);
})
d3.select("#map").append("button").attr("class", "reproject").html("Reproject to Conic Equidistant").on("click", reproject);
function reproject() {
var projection = d3.geo.conicEquidistant()
.center([0, 15])
.scale(600)
.translate(map.zoom().translate())
.precision(.1);
map.projection(projection);
map.refresh();
}
}
</script>
<body onload="makeSomeMaps()">
<div id="map"></div>
<footer>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8" type="text/javascript"></script>
<script src="https://d3js.org/topojson.v1.min.js" type="text/javascript">
</script>
<script src="https://d3js.org/d3.geo.projection.v0.min.js" type="text/javascript">
</script>
<script src="/emeeks/f3105fda25ff785dc5ed/example/tile.js" type="text/javascript">
</script>
<script src="/emeeks/f3105fda25ff785dc5ed/example/d3.quadtiles.js" type="text/javascript">
</script>
<script src="/emeeks/f3105fda25ff785dc5ed/example/d3.geo.raster.js" type="text/javascript">
</script>
<script src="https://cdn.jsdelivr.net/gh/emeeks/d3-carto-map/d3.carto.map.js" type="text/javascript">
</script>
</footer>
</body>
</html>
Modified http://d3js.org/d3.v3.min.js to a secure url
Modified http://d3js.org/topojson.v1.min.js to a secure url
Modified http://d3js.org/d3.geo.projection.v0.min.js to a secure url
Updated missing url http://bl.ocks.org/emeeks/raw/f3105fda25ff785dc5ed/tile.js to /emeeks/f3105fda25ff785dc5ed/example/tile.js
Updated missing url http://bl.ocks.org/emeeks/raw/f3105fda25ff785dc5ed/d3.quadtiles.js to /emeeks/f3105fda25ff785dc5ed/example/d3.quadtiles.js
Updated missing url http://bl.ocks.org/emeeks/raw/f3105fda25ff785dc5ed/d3.geo.raster.js to /emeeks/f3105fda25ff785dc5ed/example/d3.geo.raster.js
Updated missing url https://rawgit.com/emeeks/d3-carto-map/master/d3.carto.map.js to https://cdn.jsdelivr.net/gh/emeeks/d3-carto-map/d3.carto.map.js
https://d3js.org/d3.v3.min.js
https://d3js.org/topojson.v1.min.js
https://d3js.org/d3.geo.projection.v0.min.js
https://bl.ocks.org/emeeks/raw/f3105fda25ff785dc5ed/tile.js
https://bl.ocks.org/emeeks/raw/f3105fda25ff785dc5ed/d3.quadtiles.js
https://bl.ocks.org/emeeks/raw/f3105fda25ff785dc5ed/d3.geo.raster.js
https://rawgit.com/emeeks/d3-carto-map/master/d3.carto.map.js