Skip to content

Instantly share code, notes, and snippets.

@HarryStevens HarryStevens/.block

Last active Nov 26, 2019
What would you like to do?
license: gpl-3.0

Swiftmap is a JavaScript library for making data-driven maps.

<!DOCTYPE html>
body {
margin: 0;
#map {
width: 100%;
height: 100vh;
#map .boundary {
stroke-width: 2px;
<div id="map"></div>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
// Create the map.
var map ="#map");
d3.json("india_state.json", (error, data) => {
// Add geospatial data and draw it.
// Exposes DOM elements as D3 selections for styling.
var colors = ["#66c2a5", "#fc8d62", "#8da0cb", "#e78ac3", "#a6d854", "#ffd92f"];
.style("fill", (d, i) => colors[i % colors.length] );
// Makes it easy to create resizable maps for responsive designs.
window.onresize = function(){ map.resize(); }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.