opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

Unable to use MapView outside of MapActivity #127

Open AAverin opened 9 years ago

AAverin commented 9 years ago

MapView has onPause and onResume methods private thus non accessible outside of your library package. Meaning, I always have to extend MapActivity if I want to add a map in my project. The problem is that I already have my quite complex BaseActivity implementation, and I would like to keep all my fancy methods and utilities in it for my project.

Could you please make onPause/onResume of MapView at least protected? That way I would be able to build my custom ExtendedMapView and replace MapActivity with a custom view that can save map preferences.

hjanetzek commented 9 years ago

Dont use the MapActivity as it will soon be removed. Just use the MapView directly - oh, yes, could you try this branch https://github.com/hjanetzek/vtm/tree/viewport-sync? it should go into master the next days and already has public onPause/Resume methods.

AAverin commented 9 years ago

Here's what I did so far: https://gist.github.com/AAverin/989eef83077a6b0972f9 I'm not yet deep into details to know if this saving of latitude/longitude/scale is really need and should be done exactly that way, but just in case. That class allowed be to abstract away from MapActivity and put my map into a fragment. And I worked around onPause/onResume by calling map.pause() directly.

I'm still evaluating the library if it will suite our rather big project. So I'm if we decide to proceed that branch will already be in production.