Tag: mkuserlocation

viewForAnnotation没有移动userLocation

我已经实现了- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {方法来更改userLocation Annotation的默认位置。 在这个方法里面我使用了: if (annotation==(mapView.userLocation)) { MKAnnotationView *myAnotation = [[MKAnnotationView alloc] init]; myAnotation.image = self.userPointImage.image; myAnotation.centerOffset = CGPointMake(0, 250); return myAnotation; } else { return nil; } 其中成功将默认userLocation注释移动到中心底部。 但是,因为我也在使用标题,所以当移动我的手机时,它仍然从中心旋转地图。 – (void)locationManager:(CLLocationManager *) manager didUpdateHeading:(CLHeading *) newHeading { [self.mapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:true]; } 但userLocation注释如下。 那么该怎么做? UPDATE 我发现这个问题,并尝试应用它。 但是,因为我正在使用标题,所以它崩溃的应用程序。 在我的didUpdateUserLocation方法中,我添加了[self moveCenterByOffset:CGPointMake(0, 200) from:userLocation.coordinate]; […]

用户位置Mapkit ViewDidLoad

所以从我在这里看到的多个答案,这是如何中心和缩放应用程序加载时的用户位置,它的工作原理。 -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{ NSLog(@"Did update user location"); MKCoordinateRegion mapRegion; mapRegion.center = mapView.userLocation.coordinate; mapRegion.span.latitudeDelta = 0.2; mapRegion.span.longitudeDelta = 0.2; [map setRegion:mapRegion animated: YES]; } 但是,每当这个委托方法被调用时,当你开始使用地图的时候,它会把我带回到用户的位置。 我该如何处理这个应该停止用户位置更新? 我曾试图把这个代码在视图中加载,所以我得到的初始缩放和中心,但它不工作? 或者,也许我可以把代码放在另一个地图工具包委托方法,我只是不知道正确的做它在其他人如何做到这一点?

Swift + didUpdateUserLocation没有被调用

我无法调用MKMapView委托方法didUpdateUserLocation 。 我到目前为止做了什么: 在项目中添加框架MapKit.framwork 通过import MapKit行import MapKit视图控制器中的框架 添encryption钥在plist文件中 <key>NSLocationAlwaysUsageDescription</key> <true/> 代码在视图控制器 增加了委托didUpdateUserLocation方法来检查位置是否更新,但从来没有调用。 // MARK: – MapView delegate methods func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool) { // Calling… } func mapView(mapView: MKMapView!, didUpdateUserLocation userLocation: MKUserLocation!) { // Not getting called } // MARK: – View lifeCycle methods override func viewDidLoad() { super.viewDidLoad() var locationManager = CLLocationManager() […]

MKUserLocation点的iOS 10的标题箭头

iOS 10中的地图应用程序现在在MKUserLocation MKAnnotationView顶部包含一个标题方向箭头。 有什么方法可以在我自己的应用程序中添加这个MKMapView ? 编辑:我会很高兴做到这一点手动,但我不知道是否有可能? 我可以在地图上添加一个注释并让它跟随用户的位置,包括animation移动吗?

在保持用户位置居中的同时在MKMapView上拟合注解

我试图把所有的注释都放在我的MKMapView同时保持当前用户在地图中心的位置。 关于如何缩小地图以适应地图上的注释,已经有很多参考文献[1] [2],但是它们将调整当前的中心位置,例如,如果所有注释位于我当前用户位置的东边,它将进行调整,当前用户位置移动到地图左侧。 如何缩放我的地图,使其适合显示的所有注释,但将用户的当前位置保留在地图的中心位置? 参考文献: [1] 缩放MKMapView以适应注释引脚? [2] – (void)showAnnotations:(NSArray *)annotations animated:(BOOL)animated NS_AVAILABLE(10_9, 7_0);