Maybe1 Maybe1 - 3 months ago 28
Swift Question

Specific zoom depending annotations

I am programming an Swift application and I work with the SDK Skobbler. I would like to know if it is possible to indicate a specific zoom depending annotations.
I would to have a accurate zoom...
I know that with the routing service, there is this function which doing automatically the zoom :


routingService.zoomToRouteWithInsets(UIEdgeInsetsZero)


This is the app screenshot:

enter image description here

Answer

For ScoutMaps-iOS-SDK >= 3.0 (Skobbler >= 3.0)

self.mapView: SKMapView = SKMapView()

let topLeftCoord = CLLocationCoordinate2D(latitude: 48.267034, longitude:  5.989881)
let bottomRightCoord = CLLocationCoordinate2D(latitude: 48.248354, longitude: 6.013811)

let boundingBox = SKBoundingBox(topLeftCoordinate: topLeftCoord, bottomRightCoordinate: bottomRightCoord)

mapView.fitBounds(boundingBox, withInsets: UIEdgeInsets(top: 100, left: 100, bottom: 100, right: 100))

For ScoutMaps-iOS-SDK < 3.0 (Skobbler < 3.0)

self.mapView: SKMapView = SKMapView()

let topLeftCoord = CLLocationCoordinate2D(latitude: 48.267034, longitude:  5.989881)
let bottomRightCoord = CLLocationCoordinate2D(latitude: 48.248354, longitude: 6.013811)

let boundingBox = SKBoundingBox(topLeftCoordinate: topLeftCoord, bottomRightCoordinate: bottomRightCoord)

mapView.fitBounds(boundingBox, withPadding: CGSizeMake(100, 100))