D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mbostock
Full window
Github gist
Clipped Conic Conformal
<!DOCTYPE html> <meta charset="utf-8"> <svg width="960" height="500"></svg> <script src="https://d3js.org/d3.v4.min.js"></script> <script src="https://d3js.org/topojson.v2.min.js"></script> <script> var svg = d3.select("svg"), width = +svg.attr("width"), height = +svg.attr("height"); var graticule = d3.geoGraticule().extentMajor([[-135, 0], [135, 90]]), outline = graticule.outline(), projection = d3.geoConicConformal().fitSize([width, height], outline), path = d3.geoPath().projection(projection); var defs = svg.append("defs"); defs.append("path") .attr("id", "extent") .attr("d", path(outline)); defs.append("clipPath") .attr("id", "clip") .append("use") .attr("xlink:href", "#extent"); var g = svg.append("g") .attr("clip-path", "url(#clip)"); g.append("path") .attr("id", "graticule") .attr("fill", "none") .attr("stroke", "#777") .attr("stroke-width", 0.5) .attr("stroke-opacity", 0.5) .attr("d", path(graticule())); g.append("use") .attr("fill", "none") .attr("stroke", "#000") .attr("xlink:href", "#extent"); d3.json("https://d3js.org/world-50m.v1.json", function(error, world) { if (error) throw error; g.insert("path", "#graticule") .attr("fill", "#222") .attr("d", path(topojson.feature(world, world.objects.land))); g.insert("path", "#graticule") .attr("fill", "none") .attr("stroke", "#fff") .attr("stroke-width", 0.5) .attr("d", path(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))); }); </script>
https://d3js.org/d3.v4.min.js
https://d3js.org/topojson.v2.min.js