I have an instance of RMMapView having a route path annotation. I need to get a snapShotof the overall route because I need to use that UIImage elsewhere. Here's the code I have:
RMSphericalTrapezium trapezium = [self.mapView latitudeLongitudeBoundingBox];
[self.mapView zoomWithLatitudeLongitudeBoundsSouthWest:trapezium.southWest northEast:trapezium.northEast animated:NO];
UIImage* image = [self.mapView takeSnapshot];
However, the image has only the end point annotation and is not zoomed appropriately to include the complete route (+ start annotation and end annotation).
What's wrong with this code? How can I set the zoom levels correctly?
I use the mapbox-ios-sdk.
Zooming in this way just moves to the map's bounding box but doesn't take into account any annotations (though, it sounds strange that the entire map would not contain your annotations — I'd have to see an image to understand better).
What you probably want is to iterate all of your annotations and create a bounding box that contains all of them. This code inside of
RMAnnotation.mmay help you if you reuse it elsewhere as you iterate the map's annotations:https://github.com/mapbox/mapbox-ios-sdk/blob/abe470a4764b586ca1dc915dd0da46eb0bdef7f9/MapView/Map/RMAnnotation.m#L210-L234