Changing markers with d3.carto.map.
Each feature or point is added inside of a g element. You can then add whatever you want to that g element to create the symbols you want for your points. To do so, though, you need to use a different datum for the appended element. This doesn't seem like a good solution and will probably lead to the creation of a d3.carto.marker or equivalent at some point.
xxxxxxxxxx
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>d3.carto.map - Changing Point Markers</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;
}
</style>
<script>
function makeSomeMaps() {
map = d3.carto.map();
d3.select("#map").call(map);
map.addTileLayer("examples.map-zgrqqx0w", "Base", "mapbox", false);
map.centerOn([-0.1275,51.507],"latlong",5000);
map.addTopoJSONLayer("https://bl.ocks.org/emeeks/raw/c970c9ee3e242e90004b/sample_routes.topojson","TopoJSON","roads","svg","all");
map.addCSVLayer("https://bl.ocks.org/emeeks/raw/c970c9ee3e242e90004b/sample_points.csv","CSV Points","pinkcircle",2,"svg","x","y");
d3.select("#map").append("button").attr("class", "marker").html("Change Markers").on("click", changeMarkers);
function changeMarkers() {
csvLayer.g().selectAll("circle").remove();
csvLayer.g().selectAll("g.marker")
.append("rect")
.attr("class", "bluesquare")
.attr("height", 5)
.attr("width",5)
.attr("x",-2.5)
.attr("y",-2.5);
}
}
</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="https://d3js.org/colorbrewer.v1.min.js"></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
Modified http://d3js.org/colorbrewer.v1.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://d3js.org/colorbrewer.v1.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