Open In App

D3.js geoBoggs() Function

Last Updated : 18 Sep, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The geoBoggs() function in d3.js is used to draw the Boggs eumorphic projection. The Boggs eumorphic projection is a pseudo cylindrical, equal-area map projection used for world maps. It makes Boggs eumorphic projection from given geo JSON data.

Syntax: 

d3.geoBoggs()

Parameters: This method does not accept any parameters.

Return Value: This method returns the Boggs projection.

Example: The following example makes the Boggs projection of Asia.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
  
    <script src="https://d3js.org/d3.v4.js"></script>
  
    <script src=
    </script>
</head>
  
<body>
    <div style="width:700px; height:500px;">
        <center>
            <h4 style="color:green">
                Boggs Projection of Asia
            </h4>
        </center>
  
        <svg width="500" height="200">
        </svg>
    </div>
  
    <script>
        var svg = d3.select("svg"),
            width = +svg.attr("width"),
            height = +svg.attr("height");
  
        // Boggs projection
        var gfg = d3.geoBoggs()
            .scale(width / 1.5 / Math.PI)
            .translate([width / 2, height / 2])
  
        // Loading the json data 
        d3.json(
            "https://raw.githubusercontent.com/"
            + "janasayantan/datageojson/master/"
            + "geoasia.json",
            function (data) {
                // Draw the map
                svg.append("g")
                    .selectAll("path")
                    .data(data.features)
                    .enter().append("path")
                    .attr("fill", "black")
                    .attr("d", d3.geoPath()
                        .projection(gfg)
                    )
                    .style("stroke", "#ffff")
            })
    </script>
</body>
  
</html>


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads