gpt4 book ai didi

iphone - 使用 MKCoordinateRegion 将 MKMapView 聚焦在 NSString 经纬度坐标上

转载 作者:可可西里 更新时间:2023-11-01 03:37:51 25 4
gpt4 key购买 nike

我有一个纬度和经度坐标,我想将其作为 map 的焦点。它们存储为 NSStrings 并转换为以下位置:

NSString *placeLatitude = [elementCoords objectForKey:@"placeLatitude"];
NSString *placeLongitude = [elementCoords objectForKey:@"placeLongitude"];

CLLocationCoordinate2D location;
location.latitude = [placeLatitude doubleValue];
location.longitude = [placeLongitude doubleValue];

我如何修改下面的内容,使其不关注用户的当前位置,而是关注上面指定的纬度和经度?

MKCoordinateRegion mapRegion;
mapRegion.center = mapView.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.05;
mapRegion.span.longitudeDelta = 0.05;

最佳答案

    MKCoordinateRegion region;
CLLocation *locObj = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake([placeLatitude doubleValue], [placeLongitude doubleValue])
altitude:0
horizontalAccuracy:0
verticalAccuracy:0
timestamp:[NSDate date]];
region.center = locObj.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 1; // values for zoom
span.longitudeDelta = 1;
region.span = span;
[self.mapView setRegion:region animated:YES];

关于iphone - 使用 MKCoordinateRegion 将 MKMapView 聚焦在 NSString 经纬度坐标上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15265009/

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