Get started with topojson CDN
BSD-3-Clause licensed
GeoJSON format: TopoJSON stores large-scale, topologically valid geospatial data efficiently.
Tags:- geojson
- shapefile
Stable version
Copied!
How to start using topojson CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with topojson CDN - cdnhub.io</title>
<style type="text/css">
#map {
width: 600px;
height: 400px;
border: 1px solid black;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://cdn.cdnhub.io/topojson/3.0.2/topojson.min.js"></script>
<script>
// GeoJSON data (replace with your own data)
const geojsonData = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: { name: "Country1" },
geometry: {
type: "Polygon",
coordinates: [
[
[-12.0, 55.0],
[-11.5, 55.5],
[-11.0, 56.0],
[-10.5, 55.5],
[-10.0, 55.0],
[-10.5, 54.5],
[-11.0, 54.0],
[-11.5, 53.5],
[-12.0, 53.0],
[-12.0, 55.0],
],
],
},
},
],
};
// TopoJSON conversion
const topojsonData = topojson.feature(geojsonData, geojsonData.objects.geometries);
// Create a new SVG container
const svg = d3.select("#map")
.append("svg")
.attr("width", 600)
.attr("height", 400);
// Add the TopoJSON-converted GeoJSON data to the map
svg.datum(topojsonData).call(topojson.feature);
</script>
</body>
</html>
Copied!
Copied!
All versions
0.0.10
0.0.11
0.0.12
0.0.13
0.0.14
0.0.15
0.0.16
0.0.17
0.0.18
0.0.19
0.0.20
0.0.21
0.0.22
0.0.23
0.0.24
0.0.25
0.0.26
0.0.27
0.0.28
0.0.29
0.0.30
0.0.31
0.0.32
0.0.33
0.0.34
0.0.35
0.0.36
0.0.37
0.0.38
0.0.39
0.0.5
0.0.6
0.0.7
0.0.8
0.0.9
1.0.0
1.1.0
1.1.1
1.1.2
1.1.3
1.1.4
1.1.5
1.1.6
1.2.0
1.2.1
1.2.2
1.2.3
1.3.0
1.4.0
1.4.1
1.4.2
1.4.3
1.4.4
1.4.5
1.4.6
1.4.7
1.4.8
1.4.9
1.5.0
1.5.1
1.5.2
1.5.3
1.5.4
1.6.0
1.6.1
1.6.11
1.6.13
1.6.14
1.6.15
1.6.16
1.6.17
1.6.18
1.6.19
1.6.2
1.6.20
1.6.4
1.6.5
1.6.6
1.6.7
1.6.8
1.6.9
2.0.0
2.0.0-alpha.1
2.0.0-alpha.2
2.2.0
3.0.0
*** 3.0.2