Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically rotate/zoom? #7

Open
Jianan-Li opened this issue Apr 5, 2019 · 4 comments
Open

Programmatically rotate/zoom? #7

Jianan-Li opened this issue Apr 5, 2019 · 4 comments

Comments

@Jianan-Li
Copy link

Jianan-Li commented Apr 5, 2019

Is it possible to programmatically rotate/zoom alongside user interactions?

@Jianan-Li Jianan-Li changed the title Is it possible to programmatically rotate/zoom alongside user interactions? Programmatically rotate/zoom? Apr 5, 2019
@vasturiano
Copy link
Owner

@Jianan-Li to set the rotation/scale programmatically you don't need this module. You can do it directly on the D3 projection itself, with https://github.com/d3/d3-geo#projection_rotate and https://github.com/d3/d3-geo#projection_scale.

This module is simply aconvenience layer to control those projection parameters by means of user interaction.

@antonytrupe
Copy link
Contributor

I think this is the same thing I am experiencing...
After a user zoom and then a programmatic change of the scale via projection.scale, the next user interaction reverts the scale to the pre-programmatic value, if that makes sense. My hunch is something is storing the scale internally somewhere and ignoring the projection's current scale.

@antonytrupe
Copy link
Contributor

I'm not sure what all ev.transform.k on https://github.com/vasturiano/d3-geo-zoom/blob/master/src/geoZoom.js#L51 is based on. It seems to be 'remembering' previous zooms, which I think it needs to in order to know the change, but I don't know how to influence it so it "sees" programmatic changes to zoom/scale.

@antonytrupe
Copy link
Contributor

Found a solution. My specific case was programmatically resetting to the original orientation/scale as when zoom was added, so returning to the zoomIdentity makes geozoom aware of that.
d3.select(canvas).call(d3.zoom().transform,d3.zoomIdentity);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants