Zooming and Panning a Mercator Map centered on the Pacific using d3.js

北城以北 提交于 2019-11-28 10:01:24

I ended up working on the same problem. Here's an example (see code) where you pan left/right to rotate the projection (with wraparound), and up/down to translate (clamped by max absolute latitude), with zoom as well. Ensures that projection always fits within viewbox.

I learned a lot about zoom behavior, and projection center() and rotate() interaction.

hope this code can solve your problem

    var projection = d3.geo.equirectangular()
    .center([0, 5])
    .scale(90)
    .translate([width / 2, height / 2])
    .rotate([0, 0])
    .precision(9);

Google maps on apple products work like this. Scrol left, and you will leave one Australia, then find another and another and another

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!