Question: I'm looking for a way to fit all views with the right zoom which in my app's instance is one annotation and userlocation and the whole polyline which signifies the route connecting the annotation and the userlocation.

I have this code below which I call every time the map loads the mapview:

```
func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) {
        if let location = mapView.userLocation?.location?.coordinate, let annotations = mapView.annotations {
                let coordinate = annotations.first?.coordinate
                mapView.setVisibleCoordinateBounds(MGLCoordinateBounds(sw: location, ne: coordinate!), edgePadding: UIEdgeInsetsMake(100, 50, 100, 200 ), animated: true)
        }
    }

```

This works well for coordinates where the routes are almost linear but when the routes are a bit more complicated and long it doesn't help.

Answer: 
I have found this mapView methods which allow me to show all annotations.

```
let cameraOption = mapView.mapboxMap.camera(for: [CLLocationCoordinate2d],  padding: UIEdegInsects.zero, bearing: nil, pitch: nil)

mapView.mapboxMap.setCamera(to: cameraOption)

```

Hope this will help someone and save a lot of time :).
If you know the zoom level use [Truf's centroid](http://turfjs.org/Docs#centroid) feature to grab the centroid of the polygon, then apply it to MGL [map.flyTo](https://www.mapbox.com/mapbox-gl-js/api/#map#flyto) like this:

```
    var centroid = turf.centroid(myCoolFeatureGeometry);

    map.flyTo({
      center: centroid.geometry.coordinates,
      zoom: 19,
      curve: 1,
      screenSpeed: 4,
      easing(t) {
        return t;
      }
    });

```

If you also need the zoom level, you can get it using [Turf's bbox](http://turfjs.org/Docs#bbox) (or [envelope](http://turfjs.org/Docs#envelope)) and apply its output to MGL [map.fitbounds](https://www.mapbox.com/mapbox-gl-js/api/#map#fitbounds)

```
var features = turf.featureCollection([
  turf.point([-75.343, 39.984], {"name": "Location A"}),
  turf.point([-75.833, 39.284], {"name": "Location B"}),
  turf.point([-75.534, 39.123], {"name": "Location C"})
]);

var enveloped = turf.envelope(features);

map.fitBounds(enveloped, {
  padding: {top: 10, bottom:25, left: 15, right: 5}
});

```