d3.js geo worldmap - merge russia (shift small part from the left next to america to the right)
Asked Answered
B

1

9

I created a simple worldmap with d3 as you can see here: http://bl.ocks.org/wiesson/ef18dba71256d526eb42

shift small part to the right

Is there a simple way to shift the small part of russia (as illustrated in the picture) to the right, without creating a new topojson? If not, any other idea?

Bufflehead answered 15/12, 2015 at 19:25 Comment(0)
B
14

Okay, the answer was straightforward. As explained in the api docs, the method rotate can turn the map. So, rotate([-11, 0]) "rotated" the map in the position I was looking for.

var projection = d3.geo.mercator().scale(width / 2 / Math.PI)
    .rotate([-11, 0])
    .translate([(width) / 2, height * 1.35 / 2])
    .precision(.1);
Bufflehead answered 15/12, 2015 at 19:37 Comment(4)
Thank you so much! I have been searching for days on end!Amal
You're a time saver! Thanks!Ebert
Maybe you also figured out how to remove a line which appears there after rotate?Ebert
@GeorgiyBukharov You should have topology coordinates file. In that file you can find that small part of Russia as a separate country. Just move those topology coordinates to "Russia" MultiPolygon object. This is usually defined in JSON file. After that you should have Russia merged without line between them.Branen

© 2022 - 2024 — McMap. All rights reserved.