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

feature request: rotateable map #313

Open
Deliganli opened this issue May 30, 2016 · 12 comments
Open

feature request: rotateable map #313

Deliganli opened this issue May 30, 2016 · 12 comments

Comments

@Deliganli
Copy link

Hello all,

I will be spending some time with rotating complete map from a certain anchor point including all the map markers and so on. Would you direct me on how i should do this? So far i am rotating the map somehow but all the tiles on the viewport are not loaded correctly and also if you scroll to the borders it is not rotating anymore.

My way of rotating the canvas basically is from the TileView class like this
@Override protected void onDraw(Canvas canvas) { canvas.rotate(degrees, px, py); super.onDraw(canvas); }

Any help will be appreciated, i will make a pr as soon as i implement this.

Thanks

@moagrius
Copy link
Owner

moagrius commented May 30, 2016

Thanks for your willingness to contribute, but please understand that rotation is extremely difficult. canvas.rotate is just going to shift pixels, nothing else. Determine which tiles to decode, positioning markers, managing rotated touch delegates for markers and callouts, placing and reacting to hotspots, scroll limits, clipping, drawing paths, etc, is all based on a fixed x-y coordinate system - you would have to rewrite the majority of the library to support rotation. Additionally we support adding arbitrary views - where would they be positioned if, for example, there was a RelativeLayout with a child and rule of ALIGN_PARENT_BOTTOM? Would that be the visible bottom of the rectangle of the area, or would that be the pixel at the largest y? If it was the latter, what about undefined space - which segues to: with a fixed-size map (vs and infinite plane) you immediately run into the problem of undefined space when allowing rotation. Imagine this is your map, and the black outline is the viewport:

map-in-viewport

Now the user immediately rotates the map 25 degrees:

map-in-viewport-rotated

What happens to the undefined space? You could explicitly scroll the map to the first point where there was not undefined space, but that'd be an extremely strange UX.

If you really think you have the time and ability, by all means go ahead, and I'll be happy to take a look when done, but I personally don't foresee ever including that feature unless someone else can satisfactorily answer the questions I've outlined above.

Thanks again.

@Deliganli
Copy link
Author

Thank you for your detailed message, i will spend some time on it to look if i can find a global solution which can be integrated to the modules you have stated above.

@moagrius
Copy link
Owner

moagrius commented Jun 1, 2016

👍

@Deliganli
Copy link
Author

I did what i needed like this;

i let the map to display background colour on undefined space during rotation.
I am giving an arbitrary viewport padding which will load more tiles. So that the viewport is always being in the loaded tiles.
Then after i am overriding the onDraw method of the TileView class to rotate the canvas according to the degrees.
This action needs many gestures to be disabled and also all the click functions of the markers and everything because they are on the screen without a rotation, this just a visual rotation.

Other solution was re-setting the size of the view something like more than 3 times of the original and then after rotating the whole view with setRotation(int degrees) merhod. This makes every click event and functionality to work but with a performance cost.

They are not very good solutions so i don't think it would be a part of this library, just letting people know about it.

Thank you

@initiuminc1
Copy link

@Deliganli do you have the rotation code on any of the branches? if then i will try from my end. i too extremely need this feature

@Deliganli
Copy link
Author

@initiuminc1 i will push it on my fork when i have time

@initiuminc1
Copy link

@Deliganli thanks. Please let me know once you push. Thanks

@Deliganli
Copy link
Author

@initiuminc1 you can find it on my fork, which is not very informative maybe but i will put a sample code later on

@initiuminc1
Copy link

@Deliganli Thanks

@initiuminc1
Copy link

@Deliganli did you missed anything. i can't see any codes for setting the rotation degrees.

Thanks

@dilarakkl
Copy link

Hi. I have added my PR for this problem. You can access my branch from https://github.com/dilara91/TileView/tree/feature/rotatable-map

@moagrius
Copy link
Owner

For anyone still looking for rotation, there is a fork of version 2 from @dilara91 that has it! https://github.com/dilara91/TileView/tree/feature/rotatable-map

Thanks Dilara!

Please consider that the only version that will support rotation; we've since upped 2 majors and will not support rotation in current or future versions.

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

No branches or pull requests

4 participants