-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[android] Added dynamic scale widget to map view. #6555
Conversation
clydebarrow
commented
Oct 3, 2016
Scale is styleable via xml or programmatically for position, color and distance unit. Test activity added to TestApp in map layout category. Some minor refactoring.
Fix state not being saved in a couple of test activities
Fix potential leak of LocationListener in mapview.
@clydebarrow, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tobrun, @cammace and @bleege to be potential reviewers. |
Thank you for contributing, this seems great! |
As an outsider, my initial thought on this PR was whether a standalone widget may keep the SDK code tighter, similar to MAS. AFAIK, Google Maps doesn't have a scale bar within the Android SDK. For our mbgl demo app, the UX team wanted the scale bar to move etc. based on the chrome around the map - so I had to move the compass and add one of our (branded) android scale bars (because gravity alone wasn't going to work). Slightly topical given mapbox/mapbox-java#131 but we used RXJava to keep the code fairly clean. For example: mMetersPerPixelObservable.subscribe(mpp -> mScaleBar.setMetersPerPixel(mpp);); |
@snodnipper A valid question and one I had thought about. Firstly there is definitely some demand for the feature - there is more than one feature request lodged here for something similar, and it was something I kept looking for on my maps. Originally I implemented it outside the SDK by subclassing Looking at the SDK it became apparent that there were already models of similar widgets - the compass and the attribution - that the scale bar would sit nicely alongside both in concept and implementation. Finally, the MAS link you provided illustrates that at present there is, AFAIK, no established framework for stand-alone addons to mapbox. It's not immediately obvious (without reading the source) what that code does and whatever it is, it's just an example, not a plug-and-play widget. One question I'm ambivalent on is whether the scale bar should be enabled by default (in my PR it is.) On balance I think that's fine, because it enables easy discovery that the feature exists. |
Thanks you guys for the remarks, I ticketed the feedback into #6570. |
I'm going to add the android-future milestonefor now, we are currently planning a new release and don't want to impact stability by introducing new features at this point. We are currently thinking of merging this once the release lands. Probably in combination with refactoring in #6570. Thanks again for the contribution @clydebarrow! |
This is going to be implemented as a plugin in mapbox/mapbox-plugins-android#11 |