-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Cannot zoom to display whole world #4583
Comments
This was most likely fixed by #4504. Does the issue reproduce in version 3.2.0-beta.3? |
Can confirm no change running 3.2.0-beta.3: The map is centering correctly on (0, 0), so I don't think #4504 is at fault here... |
What does MGLMapView’s frame look like at this point? Is it possible that |
Capturing the view hierarchy using the view debugger shows that the Setting |
Note that in portrait orientation, the map would be constrained by latitude, so you wouldn’t be able to see all longitudes at once. But in landscape orientation, it should definitely be possible to see all latitudes simultaneously.
Is the current
Note that the content inset can be overridden if the map view’s superview is a UIViewController whose |
This would surely only apply if the map view is occupying the full bounds of the view. In my case, I have effectively a landscape orientation map in a portrait orientation view, so I expect it should be possible to set the dimensions of the map view such that the entire world can be viewed at once. Further, using a portrait map, it should still be possible to view all latitudes at once, shouldn't it?
I was using a constraint based layout, so at the time of initialisation the frame of the map view was 0. However, switching to manually defining the frame on initialisation, and breaking immediately after, shows the following frame allocation:
There is no difference to the map however, I am still unable to zoom out as above.
Setting this to false manually in the parent view controller does not fix the issue. |
How can display whole world? @h4rrison-james |
Closing due to ticket age. If this is still a problem, please re-open |
Experiencing the same issue. Mapbox mentions that the only projection supported is Web Mercator so the entire map projection would be square. Even when constraining the map to a square, at each side parts of the map are left out at zoom level 0. |
Are there any news on this? |
Experiencing the same thing here. |
Experiencing the same thing on Android also. |
An update on this. I discovered that it is a problem with the size of the view. Mapbox will display the entire world if the view is larger than (550, 550). When the view is smaller than 550 it will crop the map. A quick workaround is to set the size of your mapview to a value larger than 550 and then apply a CATransform to the view to scale it. Not ideal but it works. |
For those interest heres a UIView subclass that will display the entire world using Mapbox. class WholeWorldView: UIView {
let mapView = MGLMapView(frame: .zero, styleURL: MGLStyle.lightStyleURL)
init() {
super.init(frame: .zero)
clipsToBounds = true
let coordinatBounds = MGLCoordinateBounds(sw: CLLocationCoordinate2D(latitude: -60,
longitude: -170),
ne: CLLocationCoordinate2D(latitude: 84,
longitude: 195))
mapView.setVisibleCoordinateBounds(coordinatBounds, animated: false)
addSubview(mapView)
heightAnchor.constraint(equalTo: widthAnchor, multiplier: 0.65).isActive = true
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
/// The map view must be set to a minimum size of 550 and then scaled down to the bounds of the view.
/// See here for bug: https://github.com/mapbox/mapbox-gl-native/issues/4583
let maxDimension = max(bounds.width, bounds.height)
let mapDimension = max(maxDimension, 550)
let mapviewBounds = CGRect(x: 0, y: 0, width: mapDimension, height: mapDimension)
let transform = CGAffineTransform(scaleX: maxDimension / mapDimension, y: maxDimension / mapDimension)
let transformedBounds = mapviewBounds.applying(transform)
mapView.bounds = mapviewBounds
mapView.transform = transform
mapView.center = CGPoint(x: bounds.center.x, y: transformedBounds.center.y * 0.9)
}
} |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
Still valid. |
I can't seem to zoom out on mobile :( It works in Google Dev but as soon as I deploy to android it stops working. |
This was solved in GL-JS by mapbox/mapbox-gl-js#9028, and may be applicable to Native as well. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
In using the following code to instantiate a map view:
I get the following:
Which is clearly not completely zoomed out, either from a longitude or latitude perspective. Manually zooming will not let me zoom out beyond what is displayed above.
Given a correct aspect ratio, I would expect that a zoomLevel of 0 would show the entire world exactly once (i.e without wrapping).
*_Platform:iOS SDK
*_Mapbox SDK version: 3.1.2
The text was updated successfully, but these errors were encountered: