mapkit

Several and different custom Pins in the same mapView

半腔热情 提交于 2019-12-12 01:12:25
问题 This is my question.... I have a mapView and i fill the view with several custom pins. I would different custom pins in my mapView. I have tried with an IF condition but don't work. I don't understand how the called to method works. Follow the code. Vi allego il codice. //Customization of my pins - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation(id<MKAnnotation>)annotation{ static NSString *identifier = @""; MKAnnotationView *pin = [ mappa

How can I center my mapview so that the selected pin is not in the middle of the map but in 1/3 of it?

喜欢而已 提交于 2019-12-12 00:02:50
问题 I have coordinates of a single pin on my map. I try to center my map on that pin, but I don't want to keep the pin directly in the middle of the map, but in 1/3 of the screen. I tried to do it in the following workaround: let coordinateRegion = MKCoordinateRegionMakeWithDistance(coordinatesOfThePin, 500, 500) mapView.setRegion(coordinateRegion, animated: true) let frame = mapView.frame let myPoint = CGPointMake(frame.midX, frame.midY/3) let myCoordinate = mapView.convertPoint(myPoint,

MapKit adding multiple annotations from core data

爱⌒轻易说出口 提交于 2019-12-11 23:07:26
问题 This is my code. It loops for the number records in the database but only retrieves the first records lat and lon. func fetch() { let appDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let context: NSManagedObjectContext = appDel.managedObjectContext! let freq = NSFetchRequest(entityName: "Mappoints") let fetchResults = try! context.executeFetchRequest(freq) as! [NSManagedObject] self.mapView.delegate = self myData = fetchResults myData.count for _ in myData {

How to draw a route between two points(annotations) in Swift?

霸气de小男生 提交于 2019-12-11 20:47:08
问题 I would like to ask if somebody can help me with a bit of code...I don't know how to create a route in my map in Swift.I just can draw a polyline between two annotations but it goes out of the roads.How can I connect two annotations on map?but connect them on road...all these is for a bus tour.can somebody help me showing me the code for this in Swift? 回答1: In order to trace a road like this, you will need data for the road geometry, but none of Apple's APIs provide this info. You will need

MKMapView get distance between coordinates on customized route

青春壹個敷衍的年華 提交于 2019-12-11 20:25:17
问题 I have a custom route on map and want to get the distance between two coordinates on MKMapView . Below are the steps I have done so far... I have grabbed coordinate points and prepared an array of CLLocationCoordinate2D (like, customRoute = [CLLocationCoordinate2D] ). To show the route, using array of coordinates, I have drawn MKPolyline using MKOverlay method. And calculating the distance between two coordinates using distanceFromLocation method. When I calculate distance, the resulting

how to add UITextField in MKAnnotationView Title

邮差的信 提交于 2019-12-11 19:59:52
问题 I try like this, but it isn't work. How can i do this ? MKAnnotationView *pointTest = [[MKAnnotationView alloc] init]; pointTest.annotation = point; pointTest.draggable= YES; UITextField *pointText = [[UITextField alloc] initWithFrame:CGRectMake(location.latitude, location.longitude, 100, 20)]; pointText.backgroundColor = [UIColor blackColor]; pointTest.rightCalloutAccessoryView = pointText; pointTest.canShowCallout = YES; [self.userMap addAnnotation:pointTest]; 回答1: First of all, you are

iOS MapKit: How Do I Get the Map to Pan During A Marker Drag?

旧城冷巷雨未停 提交于 2019-12-11 19:48:07
问题 I've looked in vain for answers on this. In the Google Maps JavaScript API, when you drag a marker, and get close to the edge, the map pans to make room for the marker, and bring more of the map into view. This is very useful for starting at location A, then dragging to location B; even though B is currently off the map. Apparently, this is not possible in MapKit. There does not seem to be any built-in functionality for this. Fair enough. I'll write my own. I'll set up rects along the edges,

Determine which MKPinAnnotationView was selected?

霸气de小男生 提交于 2019-12-11 19:17:57
问题 I place some custom MKPinAnnotationView on the map, with different information about landmarks (name, description, image, accessory button). When a user click and open one of the pins, and then click the accessory button inside it, I want to know which of the pins the user have clicked so I can load a viewcontroller with more detailed information. I found these methods: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *

Is there any method to reset the queue used in dequeueReusableAnnotationViewWithIdentifier?

谁都会走 提交于 2019-12-11 18:41:54
问题 I add custom annotation in a mapview. Based on the internal model of the app the annotations can change color and title (although position may not change). I am using dequeueReusableAnnotationViewWithIdentifier in the method - (MKAnnotationView *)mapView:(MKMapView *) viewForAnnotation:(id <MKAnnotation>) The strange thing is that when the model changes the annotations are "refreshed" to use the correct title and color (I just use removeAnnotations: and add the new ones), but later when

MKAnnotationView pin wont appear

放肆的年华 提交于 2019-12-11 18:35:48
问题 I am new with MapKit and all its functionalities and therefore, stuck at trying to display a pin. I followed an online video tutorial on how to find user current location and drop a pin there. But when I typed the method for the pin, I do not get it at all. I would like to know where did I go wrong for this. - (void)viewDidLoad{ [super viewDidLoad]; self.title = @"Location"; mapView.showsUserLocation = YES; self.locationManager = [[CLLocationManager alloc] init]; locationManager.delegate =