mkuserlocation

User Location Mapkit ViewDidLoad

亡梦爱人 提交于 2019-12-24 15:24:00
问题 So from the multiple answers I see on here this is how to center and zoom on user location when the app loads and it works great. -(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]; } But when you start playing with the map

Fitting annotations on a MKMapView while keeping user position centered

我的梦境 提交于 2019-12-20 04:54:20
问题 I'm trying to fit all annotations on my MKMapView while keeping the current user position in center of map. There are already many references[1][2] on how to zoom out a region to fit annotations on the map but they will adjust the current center position e.g. if all annotations are located east of my current user position, it will adjust so the current user position is moved left of the map. How can I zoom my map out so it will fit all annotations shown but keep the users current position in

viewForAnnotation didn't moves the userLocation

心不动则不痛 提交于 2019-12-13 06:13:47
问题 I've implemented - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { method to change the default location of userLocation Annotation. Inside this method I've used: if (annotation==(mapView.userLocation)) { MKAnnotationView *myAnotation = [[MKAnnotationView alloc] init]; myAnotation.image = self.userPointImage.image; myAnotation.centerOffset = CGPointMake(0, 250); return myAnotation; } else { return nil; } Which successfully moves the default

Swift + didUpdateUserLocation not getting called

倖福魔咒の 提交于 2019-12-11 09:59:51
问题 I am not able to call MKMapView delegate method didUpdateUserLocation . What I did so far: Add framework MapKit.framwork in project Import framework in view controller by import MapKit line Add key in plist file <key>NSLocationAlwaysUsageDescription</key> <true/> Code in view controller Added delegate didUpdateUserLocation method to check location is updated or not but never called. // MARK: - MapView delegate methods func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool) {

MKUserLocation is selectable, falsely intercepting touches from custom MKAnnotationViews

风格不统一 提交于 2019-12-07 00:28:31
问题 I have a normal map in my iOS app where "Shows Users Location" is enabled - meaning I have my normal blue dot on the map, showing my position and accuracy info. The callout is disabled in code. But I also have custom MKAnnotationViews that are plotted around the map which all have custom callouts. This is working fine, but the problem is that when my location is on the location of a MKAnnotationView, the blue dot (MKUserLocation) intercepts the touch, so the MKAnnotationView doesn't get

MKUserLocation is selectable, falsely intercepting touches from custom MKAnnotationViews

落爺英雄遲暮 提交于 2019-12-05 04:34:06
I have a normal map in my iOS app where "Shows Users Location" is enabled - meaning I have my normal blue dot on the map, showing my position and accuracy info. The callout is disabled in code. But I also have custom MKAnnotationViews that are plotted around the map which all have custom callouts. This is working fine, but the problem is that when my location is on the location of a MKAnnotationView, the blue dot (MKUserLocation) intercepts the touch, so the MKAnnotationView doesn't get touched. How can I disable the user interaction on the blue dot so that the touches are intercepted by the

Fitting annotations on a MKMapView while keeping user position centered

狂风中的少年 提交于 2019-12-02 12:12:16
I'm trying to fit all annotations on my MKMapView while keeping the current user position in center of map. There are already many references[1][2] on how to zoom out a region to fit annotations on the map but they will adjust the current center position e.g. if all annotations are located east of my current user position, it will adjust so the current user position is moved left of the map. How can I zoom my map out so it will fit all annotations shown but keep the users current position in the center of the map? Refs: [1] Zooming MKMapView to fit annotation pins? [2] - (void)showAnnotations:

Remove user location annotation from mapView

谁说我不能喝 提交于 2019-12-02 07:51:11
问题 I have to remove all the annotations added to my MKMapView but when I execute : NSMutableArray *annotationsToRemove = [[NSMutableArray alloc] initWithArray: mapView.annotations]; [mapView removeAnnotations: annotationsToRemove]; The array annotationsToRemove contains a MKUserLocation annotation and it doesn't delete it. Is there a way to reset the map? I need to delete all the annotations from it! 回答1: You can just set the showsUserLocation property of your mapView to NO. mapView

iOS 10 heading arrow for MKUserLocation dot

自作多情 提交于 2019-11-28 20:36:26
The Maps app in iOS 10 now includes a heading direction arrow on top of the MKUserLocation MKAnnotationView . Is there some way I can add this to MKMapView in my own apps? Edit: I'd be happy to do this manually, but I'm not sure if it's possible? Can I add an annotation to the map and have it follow the user's location, including animated moves? David T I also experienced this same issue (needing an orientation indicator without having the map spin around, similar to the Apple Maps app). Unfortunately Apple has not yet made the 'blue icon for heading' API available. I created the following

iOS 10 heading arrow for MKUserLocation dot

こ雲淡風輕ζ 提交于 2019-11-27 12:19:06
问题 The Maps app in iOS 10 now includes a heading direction arrow on top of the MKUserLocation MKAnnotationView . Is there some way I can add this to MKMapView in my own apps? Edit: I'd be happy to do this manually, but I'm not sure if it's possible? Can I add an annotation to the map and have it follow the user's location, including animated moves? 回答1: I also experienced this same issue (needing an orientation indicator without having the map spin around, similar to the Apple Maps app).