gpt4 book ai didi

ios - MKPolyline 边界MapRect 插入

转载 作者:行者123 更新时间:2023-11-30 10:57:22 26 4
gpt4 key购买 nike

如何向 MKPolylineboundingMapRect 添加插图以将其与 MKMapSnapshotter 一起使用?

    let polyLine = MKPolyline(coordinates:locations , count: locations.count)

var region = MKCoordinateRegionForMapRect(polyLine.boundingMapRect)
mapSnapshotOptions.region = region

mapSnapshotOptions.scale = UIScreen.main.scale
mapSnapshotOptions.size = imageViewRect.size

mapSnapshotOptions.showsBuildings = true
mapSnapshotOptions.showsPointsOfInterest = true

let snapShotter = MKMapSnapshotter(options: mapSnapshotOptions)
snapShotter.start { (snapshot, error) in
//use snapshot
}

最佳答案

您可以向该区域添加跨度,如下所示:

// This will add a 10% increase in the span.
var region = MKCoordinateRegion(polyLine.boundingMapRect)
region.span.latitudeDelta = 1.1
region.span.longitudeDelta = 1.1

编辑:

这也是一种替代方案:

let region = polyLine.boundingMapRect
map.setVisibleMapRect(region, edgePadding: UIEdgeInsets(top: 50.0, left: 50.0, bottom: 50.0, right: 50.0), animated: true)

关于ios - MKPolyline 边界MapRect 插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53796976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com