mapkit

How to extract country and city from MKLocalSearchCompletion?

泪湿孤枕 提交于 2019-12-07 16:29:25
问题 I receive MKLocalSearchCompletion items from MKLocalSearchCompleter to its delegate. Every MKLocalSearchCompletion contains a title and a subtitle, the subtitle is an address. I need to extract a city and a country from the address. Please help! 回答1: MKLocalSearchCompletion does not "contain an address". It contains a title and subtitle. To get more information, use the MKLocalSearchCompletion to form an MKLocalSearchRequest and perform the MKLocalSearch. 回答2: Please use the following code:

Objective C - how to convert Degree-Minute-Second to Double

荒凉一梦 提交于 2019-12-07 14:06:04
问题 My actual problem is - How to obtain a CLLocation Object when the coordinate value on the map is available in Degree-Minute-Second form (as a String), instead of Double. So, I am Looking for a way to convert Degree-Minute-Second to Double, which i can use to form a CLLocation object. 回答1: I came up with a bit of a cleaner answer when figuring this out // split the string to deal with lat and lon separately NSArray *parts = [dmsString componentsSeparatedByString:@","]; NSString *latStr = parts

Identify when MKRoutestep finishes

喜夏-厌秋 提交于 2019-12-07 13:53:02
问题 I am trying to implement a turn by turn navigation system in iOS using MKDirections API. I am able to get the directions of the route and can draw the polyline on the map, and when navigation starts the app start showing the instructions using the MKRouteStep object in Steps array. Now the problem is , since the distance in the MKRouteStep object is the distance that the user covers while traversing the path of the step I am unable to identify how to calculate this distance. Is there any way

How to delete the last annotation on a mapView

假装没事ソ 提交于 2019-12-07 12:59:31
I have added a button on my .xib file with which I want to delete the last annotation that has been added. So on the Touch-Down action I have implemented this: -(IBAction)DeleteAnnotation:(id)sender { [mapview removeAnnotation:[mapview.annotations lastObject]]; } and I have even tried it this way: -(IBAction)DeleteAnnotation:(id)sender { [self.mapview removeAnnotation:self.mapview.annotations.lastObject]]; } where mapview is my MKMapView Outlet. The problem I encounter with both ways is that I have to press this specific button quite a few times before an annotation is removed. Furthermore,

Is it possible to set a fixed on-screen position for the User Location Pin on MKMapView?

 ̄綄美尐妖づ 提交于 2019-12-07 12:03:29
I'm trying to set up a MKMapView in a way that the user's location would always be offset in the top right corner of the view controller, and I would build the rest of my UI around that "block". Is there a way to set a fixed/offset center point for the MKMapView for example in a way that the pin is always at an x, y position on the screen? I can provide a sketched example if you are having trouble understanding my goal. I figured it out just now, func mapView(mapView: MKMapView!, didUpdateUserLocation userLocation: MKUserLocation!) { // Define a span (for zoom) let span: MKCoordinateSpan =

iOS 6 Map doesn't zoom with MKUserTrackingModeFollow

一曲冷凌霜 提交于 2019-12-07 11:13:38
问题 While my iOS6 MKMapView is in MKUserTrackingModeFollowWithHeading or MKUserTrackingModeFollow , zoom gestures (pinch, double-tap, two-finger tap) work sometimes, but not always. The issue seems to occur when didUpdateUserLocation: is called after regionWillChangeAnimated and before regionDidChangeAnimated . Any ideas on how to fix this? To isolate the problems, I've created a Single View Application with an MKMapView and a UIToolbar (set up in a .xib), to which I'm adding a

iOS how can I make MapKit display custom indoor map?

时间秒杀一切 提交于 2019-12-07 10:33:02
问题 I'm trying to create a map of the office I'm working at. I have a high resolution image, and would like to autorotate it in the direction the user is heading, allowing the user to navigate around the map. I thought this could be accomplished using CoreMotion/CoreLocation and a UIScrollView, but this seems like there's some work involved. So I'm wondering if there are easier solutions for combining a custom map and direction/position on that map - can MapKit handle this for me? Are there other

MapKit How to pass managedObject from mapView to mapDetailView

若如初见. 提交于 2019-12-07 09:57:30
I am trying to pass a managedObject from a mapView with multiple annotation to a mapDetailView with only one annotation of the managedObject passed. This works great in a tableView to mapDetaiView. Any help would be appreciated. My code ... - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { self.managedObjectContext = [(CrossroadsTreasuresAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; } // setup the mapView [mapView removeAnnotations:mapView.annotations]; [mapView setMapType:MKMapTypeStandard]; [mapView setZoomEnabled:YES];

Calculating heading of compass to a specific coordinate instead of to north

爷,独闯天下 提交于 2019-12-07 09:33:37
问题 I can't get this algorithm right. I'm trying to make a compass that points at a certain location instead of just pointing to, let's say, north. Something is wrong. I've spent a lot of time trying to figure this out, but i just can't find it. Any ideas? - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{ double distanceEast = (location.longitude > 0 && otherLocation.longitude < 0) ? 180 - location.longitude + otherLocation.longitude - -180:

Adding MKOverlayPathRenderer as overlay to MKMapView gets exception

吃可爱长大的小学妹 提交于 2019-12-07 08:35:27
Everything said in topic, so here is the code - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _pathRenderer = [[MKOverlayPathRenderer alloc] init]; _pathRenderer.lineWidth = 8.0f; _pathRenderer.strokeColor = [UIColor redColor]; _pathRenderer.path = CGPathCreateMutable(); [_mapView addOverlay:_pathRenderer]; } At the last line it drops with exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKOverlayPathRenderer boundingMapRect]: unrecognized selector It means that i'm using wrong