Mapbox SDK versions: 5.1.1


Thanks @racer1988!
Automatically hiding the scale bar at ~z1-z4 is actually intentional and is mildly documented:
The scale bar may not be shown at all zoom levels.
Here鈥檚 the logic that controls the allowable range of distances the scale bar can show:
We can consider this as a feature request, though 鈥斅爉uch as we鈥檙e adding visibility customization to the compass (https://github.com/mapbox/mapbox-gl-native/issues/9562#issuecomment-316772669), we could follow MapKit鈥檚 lead again and add a similar configuration option to the scale bar.
@friedbunny I am happy to it not be shown at zoom 1-4.
However this is a Bug.
The Scale Bar is shown Squashed.
check the screenshot. the arrow points to what is the visible scalebar
Ah, I see, apologies @racer1988... I can鈥檛 reproduce this bug, in that case. 馃槃 The labels do bunch up after the bar disappears (which isn鈥檛 great), but they also disappear very quickly (~hundreds of milliseconds) soon after.
Could you say more about how鈥檙e you鈥檙e using the scale bar? Is it enabled via MGLMapView.showsScale or more directly via MGLMapView.scaleBar.hidden?
I Hide the scalebar with a timer when the user stop zooming:
UIView.animate(withDuration: 0.3, delay: 0.0, options: .beginFromCurrentState, animations: { [weak self] in
self?.mapView.scaleBar.alpha = 0.0
}) { [weak self] _ in
self?.mapView.showsScale = false
}
and when the zoom starts I show it
mapView.scaleBar.alpha = 1.0
mapView.showsScale = true
@friedbunny Found a way to reproduce consistently.
for me the squashed labels are disappearing only after the gesture is finished completely.
So if I zoom back and keep my fingers on the map, the labels stay squashed.
In that case the label and the bar should disappear together and not be indipendentely hidden (at different times)
private func handleZoomOnScale() {
guard configuration.showsScale else {
return
}
mapView.scaleBar.alpha = 1.0
mapView.showsScale = true
hideScaleTimer?.invalidate()
hideScaleTimer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false, block: { [weak self] (timer) in
guard timer.isValid else {
return
}
self?.hideScale()
})
}
private func hideScale(animated: Bool = true) {
hideScaleTimer?.invalidate()
hideScaleTimer = nil
guard animated == true else {
mapView.showsScale = false
return
}
UIView.animate(withDuration: 0.3, delay: 0.0, options: .beginFromCurrentState, animations: { [weak self] in
self?.mapView.scaleBar.alpha = 0.0
}) { [weak self] _ in
self?.mapView.showsScale = false
}
}
func mapView(_ mapView: MGLMapView, regionIsChangingWith reason: MGLCameraChangeReason) {
if reason.contains(.gesturePinch) ||
reason.contains(.gestureZoomIn) ||
reason.contains(.gestureZoomOut) {
handleZoomOnScale()
}
}
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.