question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to rotate albersUsa projections

See original GitHub issue

This is not a critical issue, however, I noticed that I am only able to apply rotation to specific d3.geo projections. I cannot apply rotation to an albersUsa projection https://github.com/d3/d3-3.x-api-reference/blob/master/Geo-Projections.md

  function makeUsaProjection(scale) {
    return function(element) {
      var projection =  d3.geo.albersUsa()
      .scale(scale? scale : (element.width + 1) / 2 / Math.PI)
      .translate([element.offsetWidth / 2, element.offsetHeight / (2)]);

      var path = d3.geo.path()
      .projection(projection);

      return {path: path, projection: projection};
    }
  }

The code above will generate albersUsa map for me, however, when I specify a rotation on my projection:

.rotate([10,10,10])

I receive the following error:

explore-maps.js:497 Uncaught TypeError: d3.geo.albersUsa(…).rotate is not a function

I’m not sure why I can apply rotations to specific projections, and not the albersUsa map.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mbostockcommented, Sep 29, 2016

Also see d3-composite-projections for more projections that use the same technique as d3.geoAlbersUsa.

0reactions
Fallenstedtcommented, Oct 3, 2016

Incase anyone comes wondering how they can rotate their albsersUsa projection, I dug through object that is generated and applied a style via javascript:

var usaSvg = map.svg[0][0].childNodes[0]; var dotsSvg = map.svg[0][0].childNodes[1];

usaSvg.setAttribute('transform', 'rotate(-2)'); dotsSvg.setAttribute('transform', 'rotate(-2)');

Read more comments on GitHub >

github_iconTop Results From Across the Web

albersUsa Projection #48 - zcreativelabs/react-simple-maps
albersUsa doesn't have a rotate function and ZoomableGroup expects rotate to exist. One possible workaround would be to add a rotate function ...
Read more >
d3js - how to set albers projection properly? - Stack Overflow
Now, d3.js use combination of projection.rotate and projection.center to place center of the projection to long 98°W, lat 38°N (around Hutchinson, Kansas).
Read more >
Is it poor form to rotate Albers US state projections if you're ...
We are using the Albers US map in a project with Alaska and Hawaii shown as well. The project allows users to zoom...
Read more >
topojson projections and extensions in geojsonio - RDRR.io
If rotation is specified, sets the projection's three-axis rotation to the specified angles yaw, pitch and roll (or equivalently longitude, ...
Read more >
Plot: Projections - Observable
The rotate option is an array of two (or three) angles—called Euler ... (Note that, in cases where Plot is unable to fit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found