让MKMapView只放大centerCoordinate? [英] Make MKMapView only zoom in on the centerCoordinate?

查看:84
本文介绍了让MKMapView只放大centerCoordinate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个始终位于地图中心的MKPinAnnotationView。平移和缩放
时,引脚会给出地图的中心坐标(纬度/经度)。

I have a MKPinAnnotationView that is always in the center of the map. When panning and zooming the pin gives me the center coordinates (lat/long) of the map.

目前,当您放大时,它只会放大您指示地图放大的位置。

Currently when you zoom in, it just zooms into wherever your directing the map to zoom into.

I我真的很想把变焦锁定在别针上。

I'd really like to lock the zoom onto the pin.

关于我如何实现这个目标的任何想法?

Any ideas on how I'd achieve this?

推荐答案

假设MKPinAnnotation是指MKPinAnnotationView,您可以访问注释的坐标并使用它来创建一个区域,然后将mapView的区域设置为以坐标为中心的区域:

Assuming by MKPinAnnotation you mean MKPinAnnotationView, you can access the annotation's coordinate and use that to create a region and subsequently set the region of the mapView to that region centered on the coordinate:

MKCoordinateRegion region = MKCoordinateRegionMake(pin.annotation.coordinate, MKCoordinateSpanMake(.05, .05));
[self.mapView setRegion:region animated:YES];

这篇关于让MKMapView只放大centerCoordinate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆