如何放大用户当前位置

如何放大用户当前位置

本文介绍了如何放大用户当前位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用程序在MapKit中启动时,我想放大用户的当前位置.这是我的代码(在viewDidLoad函数中):

I wanna zoom into the user current location when the app starts in the MapKit.This is my code (in the viewDidLoad function):

Locate=[[CLLocationManager alloc]init];
Locate.delegate=self;
Locate.desiredAccuracy=kCLLocationAccuracyBestForNavigation;
Locate.distanceFilter=kCLDistanceFilterNone;
[Locate startUpdatingLocation];
[super viewDidLoad];

//Region
MKCoordinateRegion myRegion;

//Center
CLLocationCoordinate2D center;
center.latitude=Locate.location.coordinate.latitude;
center.longitude=Locate.location.coordinate.longitude;

//Span
MKCoordinateSpan span;
span.latitudeDelta=0.3f;
span.longitudeDelta=0.3f;
//Set Region
myRegion.center=center;
myRegion.span=span;
[_MyMap setRegion:myRegion animated:YES];

我还用与以前相同的代码实现了didUpdateLocation函数.问题是,当用户位置更改时(用户移动时),屏幕会放大他的位置,但我无法移动屏幕,如果尝试移动它,则会立即返回到用户位置,所以我无法查看整个地图.

Also I implemented the didUpdateLocation function with the same code as previous.The problem is that when the user location is changing (when the user is moving) the screen makes zoom at him but I can't move the screen, if I try to move it return to the user location immediately, so I can't see the whole map.

推荐答案

我通过添加touchesMoved函数解决了此问题,并且停止在此函数中更新Location.解决了.​​

I solved this issue by adding touchesMoved function and I stopped updating the Location in this function.Solved.

这篇关于如何放大用户当前位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:15