gpt4 book ai didi

ios - MapView 不显示正确的点

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

刚刚开始使用MapKit框架,第一次实践并不顺利:)

除了 MapView 显示在海洋中的某处并且它没有找到任何地方(例如:陆地、岛屿)之外,一切似乎都运行良好。我认为纬度和经度不知何故超出了范围。

这是我的代码:

    - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIBarButtonItem *zoomButton =
[[UIBarButtonItem alloc]
initWithTitle: @"Zoom-In"
style:UIBarButtonItemStyleBordered
target: self
action:@selector(zoomIn:)];

UIBarButtonItem *typeButton =
[[UIBarButtonItem alloc]
initWithTitle: @"Zoom-Out"
style:UIBarButtonItemStyleBordered
target: self
action:@selector(zoomOut:)];

NSArray *buttons = [[NSArray alloc]
initWithObjects:zoomButton, typeButton, nil];

barButtons.items = buttons;



MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);

MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];

zoomLocation.latitude = 48.431638;
zoomLocation.longitude= 27.169436;
annotationPoint.coordinate = zoomLocation;
annotationPoint.title = @"My Company";
annotationPoint.subtitle = @"my Company Title";


//[self __mapView];

MKCoordinateRegion adjustedRegion = [__mapView regionThatFits:viewRegion];

[__mapView setRegion:adjustedRegion animated:YES];

[__mapView addAnnotation:annotationPoint];
}

最佳答案

您在创建区域后设置 zoomLocation 坐标。首先尝试设置 zoomLocation

...
zoomLocation.latitude = 48.431638;
zoomLocation.longitude= 27.169436;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
...

关于ios - MapView 不显示正确的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15480292/

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