gpt4 book ai didi

ios - 如何在 iOS 中设置缩放级别?

转载 作者:行者123 更新时间:2023-11-29 02:28:40 25 4
gpt4 key购买 nike

我正在使用下面给出的代码在 map View 中设置区域:

    CLLocationCoordinate2D loc = (CLLocationCoordinate2D )[self geoCodeUsingAddress:searchBar.text];

CLLocationDistance visibleDistance = 100000;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, visibleDistance, visibleDistance);
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:region];

[self.mapView setRegion:adjustedRegion animated:YES];
[self.mapView setCenterCoordinate:loc];
[self.mapView setZoomEnabled:YES];

它在一个小区域内显示整个 map 。如何增加缩放级别?

最佳答案

您还可以借助 MapView 的 span 值。为那个小区域制作动画并跨度 map 以缩放所需的值。

使用下面的代码:

CLLocationCoordinate2D loc = (CLLocationCoordinate2D )[self geoCodeUsingAddress:searchBar.text];

[UIView animateWithDuration:1.5 animations:^{

MKCoordinateRegion region;
region.center.latitude = loc.latitude;
region.center.longitude = loc.longitude;
region.span.latitudeDelta = 0.15f; // Decrement value to zoom
region.span.longitudeDelta = 0.15f; // Decrement value to zoom

[self.mapView setRegion:region animated:YES];

} completion:^(BOOL finished) { }];

关于ios - 如何在 iOS 中设置缩放级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27182907/

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