p-lr / MapView

A Fast, memory efficient Android library to display tiled maps, with support for markers, paths, and rotation.
Apache License 2.0
184 stars 38 forks source link

Map view rotation feature #2

Closed srbhagwatsrb closed 4 years ago

srbhagwatsrb commented 4 years ago

I am building a POC for Indoor navigation and i came across TIleview as well as MapView. I would like to use Kotlin version. But i did not find demo on having a rotatable map. Is it possible to rotate the map?

What i want is that in my indoor navigation app, based on magnetic field directions, map should get adjusted/rotated in order to show FPP view. (First person perspective view). Do you have any info on how this can be achieved?

p-lr commented 4 years ago

I would use the setRotation method available on every View since api level 11. Apply to the MapView or one of it's parent view in your app. Link to doc: https://developer.android.com/reference/android/view/View.html#setRotation%28float%29

srbhagwatsrb commented 4 years ago

Hmm but I need something like Google map rotation. On drag and rotate on a zoompanlayout. Could you please guide?

p-lr commented 4 years ago

In the meantime, I had more time to think about it. The proper way to support this would require some adaptations of the library. Indeed, the rotated map needs to update the visible tiles, which cannot be achieved by simply rotating the MapView. So MapView currently doesn't support this feature. Although it might be added the future, either when I have time to do this or someone makes a PR.

srbhagwatsrb commented 4 years ago

RIght i was thinking about the same. It's really a good feature to add. And may be i will have to use an old version of tileview (2.x) where someone have done this. I do not want to use an old version again. Any chance this feature can be implemented soon in this also?

p-lr commented 4 years ago

I can't make promises. But when it's done, it will be very easy for you to migrate, as TileView 2 API is very similar to MapView. Basically you have a BitmapProvider instead of TileStreamProvider, and have to define manually the levels.

Note to self: a GestureDetector

srbhagwatsrb commented 4 years ago

Thanks @peterLaurence Do try to add this soon as it will be extremely good to use. This map view is already in production grade. So with rotatable map it will work great in all real time apps. Great work on this library.

p-lr commented 4 years ago

I have a very promising proof of concept of rotating map in my rotation branch. But it's not ready yet. Will you be available to beta test when it's done? (I hope soon)

shriharsha-bhagwat commented 4 years ago

Sure i will be ready to test it out. Let me know.

p-lr commented 4 years ago

Perfect. I'm making progress - paths rotation and a few optimizations need to be done. I let you know. Thanks

p-lr commented 4 years ago

@android-bash It has been harder and longer than I thought. I've published the version 2.0.0-beta04

The API around map rotation is stable (although I might make slight changes before final release). 2.x.x is a major shift from 1.x.x as it enables map rotation. It's only an opt-in feature, while configuring the MapView, using enableRotation(). The RotatingMapFragment from the demo is an example.

Beware that there are some breaking changes. Most of the time, it's just a package name change. The ScaleChangeListener interface has been removed. If you relied on this, I can explain how to do the equivalent in 2.x.x

p-lr commented 4 years ago

Implemented in 2.0.0