Skip to content

Instantly share code, notes, and snippets.

@AnupJoseph
Created November 15, 2021 07:28
Show Gist options
  • Save AnupJoseph/b4fc9a3eacc006ea5e5e20bb8f2c56d4 to your computer and use it in GitHub Desktop.
Save AnupJoseph/b4fc9a3eacc006ea5e5e20bb8f2c56d4 to your computer and use it in GitHub Desktop.
Map with Svelte
<script>
import { json } from "d3";
import Marks from "./Marks.svelte";
let dataset = [];
json(
"https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson"
).then((data) => {
dataset = data.features;
});
const width = 1200,
height = 600;
</script>
<main>
<svg {width} {height}>
<Marks {dataset} />
</svg>
</main>
<script>
import { geoPath, geoNaturalEarth1 } from "d3";
export let dataset = [];
import { draw } from "svelte/transition";
import { quadInOut } from "svelte/easing";
const projection = geoNaturalEarth1();
const path = geoPath(projection);
</script>
{#each dataset as data}
<path
transition:draw={{ duration: 5000, delay: 0, easing: quadInOut }}
d={path(data)}
/>
{/each}
<style>
path {
fill: none;
stroke: darkgreen;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment