Skip to content Skip to sidebar Skip to footer

Projection([lat,lng]) Keeps Returning Null

I'm trying to map several points from a GeoJSON file onto a map using the albersUsa projection. My code is as follows, but it fails to add the cx and cy attributes to the circle el

Solution 1:

You're calling the projection incorrectly -- it needs to be given a pair of coordinates:

.attr("cx", function(d) {
        var longitude = d.geometry.coordinates[1];
        var latitude = d.geometry.coordinates[0];
        return projection([longitude, latitude])[0];
    })
    .attr("cy", function(d) { 
        var longitude = d.geometry.coordinates[1];
        var latitude = d.geometry.coordinates[0];
        return projection([longitude, latitude])[1];
    })

Post a Comment for "Projection([lat,lng]) Keeps Returning Null"