datamaps icon indicating copy to clipboard operation
datamaps copied to clipboard

NEW FEATURE: make orthographic maps rotatable

Open unilogue opened this issue 10 years ago • 6 comments

an option to make orthographic maps rotatable, based on this example by jason davies.

i've also created an issue.

unilogue avatar Dec 13 '15 23:12 unilogue

@unilogue Can you put your code edit just inside of /src/js/datamaps.js instead of the built file?

markmarkoh avatar Dec 15 '15 03:12 markmarkoh

@markmarkoh that's the thing, i don't know how to incorporate the code from that file into the datamaps.js, it seems to be incompatible. i just wanted to post that as an example, i was hoping someone would know how to implement this feature into datamaps..

unilogue avatar Dec 15 '15 04:12 unilogue

This looks like it could work! Taken from here.

I tried copying it into a done callback but nothing happened, any ideas?

    var dragBehaviour = d3.behavior.drag()
    .on('drag', function(){
        var dx = d3.event.dx;
        var dy = d3.event.dy;

        var rotation = projection.rotate();
        var radius = projection.scale();
        var scale = d3.scale.linear()
            .domain([-1 * radius, radius])
            .range([-90, 90]);
        var degX = scale(dx);
        var degY = scale(dy);
        rotation[0] += degX;
        rotation[1] -= degY;
        if (rotation[1] > 90)   rotation[1] = 90;
        if (rotation[1] < -90)  rotation[1] = -90;

        if (rotation[0] >= 180) rotation[0] -= 360;
        projection.rotate(rotation);
        redraw();
    })

unilogue avatar Dec 17 '15 05:12 unilogue

Any solution for this?

h0jeZvgoxFepBQ2C avatar Feb 01 '18 10:02 h0jeZvgoxFepBQ2C

yup! https://stackoverflow.com/questions/33850471/make-d3-js-datamap-rotate-by-dragging-with-cursor

unilogue avatar Feb 01 '18 12:02 unilogue

Is there a way to make the map auto rotate?

S-Simon avatar Feb 12 '19 09:02 S-Simon