← Examples
countries · high detail · country name filter · geojson

Martinique

A French overseas territory in the Caribbean. The filter parameter accepts full country names — no ISO code lookup required. At detail=high the API uses the 10m Natural Earth dataset, large enough to render this 1,128 km² island clearly. The projection auto-fits to the returned geometry using fitExtent.

API Call

https://api.mapjson.com/v1/geo?layer=countries&filter=Martinique&detail=high&format=geojson

Code

<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
  <style>svg { width: 100%; display: block; background: #7ab4cc; }</style>
</head>
<body>
  <div id="map"></div>
  <script>
    const width = 960, height = 560;
    const svg = d3.select("#map").append("svg").attr("viewBox", `0 0 ${width} ${height}`);

    const url = "https://api.mapjson.com/v1/geo?layer=countries&filter=Martinique&detail=high&format=geojson";

    d3.json(url).then(geojson => {
      const projection = d3.geoMercator()
        .fitExtent([[80, 60], [width - 80, height - 60]], geojson);
      const path = d3.geoPath().projection(projection);

      svg.selectAll("path")
        .data(geojson.features)
        .join("path")
        .attr("d", path)
        .attr("fill", "#d9d0be")
        .attr("stroke", "#7ab4cc")
        .attr("stroke-width", 1);
    });
  </script>
</body>
</html>