我正在编写一个Swift应用程序,我使用SDK Skobbler。我想知道是否可以根据注释指示特定的缩放。 我想要准确的缩放...... 我知道使用路由服务,有这个功能可以自动进行缩放:
routingService.zoomToRouteWithInsets(UIEdgeInsetsZero)
这是应用截图:
答案 0 :(得分:1)
尝试以下代码
let boundingBox = SKBoundingBox(topLeftCoordinate: CLLocationCoordinate2DMake(track.ne.coordinate.latitude, track.sw.coordinate.longitude), bottomRightCoordinate: CLLocationCoordinate2DMake(track.sw.coordinate.latitude, track.ne.coordinate.longitude))
// Add the mapView to the view just to see if it displays correctly. (It does!)
mapView.fitBounds(boundingBox, withPadding: CGSizeMake(20, 20))
答案 1 :(得分:0)
对于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))
对于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))