如何使 MKMapView 从顶部进入
Posted
技术标签:
【中文标题】如何使 MKMapView 从顶部进入【英文标题】:How to make a MKMapView come in from the top 【发布时间】:2016-05-01 12:16:08 【问题描述】:我有一个带有基本 MKAnnoation 的普通 MKMap 视图,我想要完成的是我的注释在英国并且 MKCoordinateSpan 是 0.05,但我希望 MKMapView 从整个英国的视图开始并放大到注释.
【问题讨论】:
【参考方案1】:- (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];
/* set here the region from where map will be zooming; */
[self.mapView setRegion:MKCoordinateRegionForMapRect(MKMapRectWorld) animated:NO];
- (void)viewDidAppear:(BOOL)animated
[super viewDidAppear:animated];
/* set here your end point of zooming */
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 39.281516;
zoomLocation.longitude= -76.580806;
[self.mapView setCenterCoordinate:zoomLocation animated:YES];
CLLocationDistance locationDistance = [self locationDistance:0.5];
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, locationDistance, locationDistance);
[self.mapView setRegion:viewRegion animated:YES];
- (CLLocationDistance )locationDistance:(CGFloat )value
return 1609.344 *value;
【讨论】:
以上是关于如何使 MKMapView 从顶部进入的主要内容,如果未能解决你的问题,请参考以下文章
如何在 MKMapView 中将图钉和地图保持在移动叠加层上方的中心
使 MKMapView 的背景颜色变暗而不使 MKOverlay 变暗