mapkit

Centering map against user's location

送分小仙女□ 提交于 2019-12-08 04:37:37
问题 I'd like to center a map (mapkit) against the user's location. I do the following in the simulator but only get a blue map with no content. What steps should I be taking? MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta=0.2; span.longitudeDelta=0.2; CLLocationCoordinate2D location; location.latitude = mapView.userLocation.location.coordinate.latitude; location.longitude = mapView.userLocation.location.coordinate.longitude; region.span=span; region.center=location; [self

MapKit How to pass managedObject from mapView to mapDetailView

帅比萌擦擦* 提交于 2019-12-08 04:19:59
问题 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

How to find direction between two location in iPhone application?

冷暖自知 提交于 2019-12-08 04:18:46
问题 I am trying to find direction between two location using iOS framework but I am not able to find proper solution . 回答1: You can use different methods for finding the direction between two location. (1) Using Google Maps NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString

Draw a polyline between two coordinates in Xcode

流过昼夜 提交于 2019-12-08 02:53:49
问题 I would like to draw a POLY-LINE between two or more given coordinates on the map(poly-line and not the route). Imagine I have 2 dropped pins on the map and I need to draw a straight line from the first dropped pin to the second dropped pin. 回答1: In Interface file MKPolyline* _routeLine; MKPolylineView* _routeLineView; In Implementation file Store all the coordinates in NSMutablrArray *routeLatitudes then MKMapPoint* pointArr = malloc(sizeof(CLLocationCoordinate2D) * [routeLatitudes count]);

Animated MKOverlayView

可紊 提交于 2019-12-08 01:46:41
问题 I've run across a couple of similar questions here regarding getting an animated MKOverlayView working property with decent performance (e.g., an animated radar overlay). However, while the answers have helped lead me in the right direction, I still don't fully grasp what I'm missing yet. I've been trying to get this UIImageView method working, which simply adds an UIImageView as a subview of the MKOverlayView, then adds the necessary images in the animation sequence to its animationImages

Show current position annotation by default

北城余情 提交于 2019-12-08 00:59:17
问题 I have an current location annotation (blue dot) showing in mapkit. Annotation shows after taping the blue dot, how can I have the annotation showing by default?, when I start the view? whit out tapping the pin. - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views { for(MKAnnotationView *annotationView in views) { if(annotationView.annotation == mv.userLocation) { self.mapView.userLocation.title= @"Current"; self.mapView.userLocation.subtitle= @"Location"; MKCoordinateRegion

How to get location name using mapkit in iphone?

旧巷老猫 提交于 2019-12-07 21:49:00
问题 I am new in iphone development and right now i am facing problem for developing developing an application in which i need to get coordinate(lat, long) when user tapped on screen for two second and also get user location name,i got coordinate but i am unable to get user location name on which user tapped. so kindly help me on that? 回答1: In iOS 5+ use CLGeocoder and its reverseGeocodeLocation:completionHandler: method. In your case, you're probably most interested in the areasOfInterest

Why calloutAccessoryControlTapped is called for tap on annotation view also?

风格不统一 提交于 2019-12-07 20:11:23
问题 I have a map on my view controller and I don't know why but the delegate calloutAccessoryControlTapped is also called when I just tap on annotation view, not only when I tap on detail closure . So why this behavior? import UIKit import MapKit extension MapVC: MKMapViewDelegate, CLLocationManagerDelegate { func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { ... } } 回答1: As per Apple developer docs: Accessory views contain

Reverse function of MKCoordinateRegionMakeWithDistance?

左心房为你撑大大i 提交于 2019-12-07 17:47:09
问题 MapKit's built in function MKCoordinateRegionMakeWithDistance takes distances in meters and turns them into a MKCoordinateRegion : func MKCoordinateRegionMakeWithDistance( _ centerCoordinate: CLLocationCoordinate2D, _ latitudinalMeters: CLLocationDistance, _ longitudinalMeters: CLLocationDistance) -> MKCoordinateRegion is there a reverse function that takes a MKCoordinateRegion and gives me latitudinalMeters and longitudinalMeters? 回答1: MKCoordinateRegion gives a center (latitude and

MKOverlayRenderer to display UIImage over map view

点点圈 提交于 2019-12-07 17:13:53
问题 I'm trying to display an image over a map view in iOS 7. I subclassed MKOverlayRenderer as follows: MapOverlayRenderer.h #import <Foundation/Foundation.h> @import MapKit; @interface MapOverlayRenderer : MKOverlayRenderer @end MapOverlayRenderer.m #import "MapOverlayRenderer.h" @implementation MapOverlayRenderer - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { UIImage *image = [UIImage imageNamed:@"marker"]; CGImageRef imageReference =