mkmapview

How to delete all Annotations on a MKMapView

怎甘沉沦 提交于 2019-12-17 15:26:38
问题 Is there a simple way to delete all the annotations on a map without iterating through all the displayed annotations in Objective-c? 回答1: Yes, here is how [mapView removeAnnotations:mapView.annotations] However the previous line of code will remove all map annotations "PINS" from the map, including the user location pin "Blue Pin". To remove all map annotations and keep the user location pin on the map, there are two possible ways to do that Example 1, retain the user location annotation,

Add Modal Popup to Map Annotation - Swift 3.0

你说的曾经没有我的故事 提交于 2019-12-17 14:58:17
问题 I have a number of custom pins on a map and when a user taps a pin and then the button on the Callout View I would would to add a function that launches a Modal Popup using Scene Dock Here is my code: func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { // here I would like to launch a Modal Popup using Scene Dock popInfo.center = view.center popInfo.transform = CGAffineTransform(scaleX: 0.8, y: 1.2) self.view.addSubview

Is there a way to add text using Paths Drawing

北城余情 提交于 2019-12-17 09:47:51
问题 I have a map custom view that inherit from MKOverlayPathView. I need this custom view to display circle, line and text. I already managed to draw circle and line using path drawing CGPathAddArc and CGPathAddLineToPoint functions. However, I still need to add text. I tried to add text using [text drawAtPoint:centerPoint withFont:font]; but I got invalid context error. any idea? 回答1: With MKOverlayPathView , I think the easiest way to add text is to override drawMapRect:zoomScale:inContext: and

How do I zoom an MKMapView to the users current location without CLLocationManager?

江枫思渺然 提交于 2019-12-17 08:01:41
问题 With the MKMapView there's an option called "Show users current location" which will automatically show a users location on the map . I'd like to move and zoom to this location when it's found (and if it changes). The problem is, there doesn't appear to be any method called when the user location is updated on the map , so I have nowhere to put the code that will zoom/scroll . Is there a way to be notified when an MKMapView has got (or updated) the user location so I can move/zoom to it? If I

How do I zoom an MKMapView to the users current location without CLLocationManager?

久未见 提交于 2019-12-17 08:00:57
问题 With the MKMapView there's an option called "Show users current location" which will automatically show a users location on the map . I'd like to move and zoom to this location when it's found (and if it changes). The problem is, there doesn't appear to be any method called when the user location is updated on the map , so I have nowhere to put the code that will zoom/scroll . Is there a way to be notified when an MKMapView has got (or updated) the user location so I can move/zoom to it? If I

Draw text in circle overlay

冷暖自知 提交于 2019-12-17 07:37:34
问题 I'm trying to draw some circle overlays containing text on MKMapView. I have subclassed the MKCircleView, in which I put the following (based on this), but the text does not appear. The circles show up correctly. (Also tried the first response's solution, same result). -(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { [super drawMapRect:mapRect zoomScale:zoomScale inContext:context]; NSString * t= @"XXXXX\nXXXX" ; UIGraphicsPushContext

MKMapView annotations changing/losing order?

北城余情 提交于 2019-12-17 06:52:13
问题 I have a map view with annotations, and these annotations display a callout. When the callout's disclosure detail button is clicked, it segues into a new view. My MKAnnotations are a custom class that implements <MKAnnotation> . Let's call that class MyClass. They are stored in an NSMutableArray. During viewdidload of this view, I add each object of MyClass in this array to the map view's annotations. Using the debugger, I can see that once all of this adding is done, the [self.MapView

Annotation details after detail disclosure pressed?

大城市里の小女人 提交于 2019-12-17 03:21:30
问题 I have a MKMapView annotation object that has a right callout accessory detail disclosure button. When the button is pressed I am using addTarget:action:forControlEvent to call a selector method which creates a detail viewController and pushes it onto the view stack. My question is what is the best way to access the information on the annotation that initiated the callout detail controller. The detail disclosure button is set to call: [button addTarget:self action:@selector(disclosurePressed:

Show route between current and desired location on iPhone MapView

匆匆过客 提交于 2019-12-14 03:39:27
问题 I want to show a route on a MKMapView between the current location and a desired location as an annotation. What is the best way to do this? 回答1: ///in .h add delegate MKMapViewDelegate ///in .m file - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocationCoordinate2D newcordinate = newLocation.coordinate; CLLocationCoordinate2D oldcordinate = oldLocation.coordinate; MKMapPoint * pointsArray = malloc

CalloutAccessoryView view for MKPinAnnotationView

…衆ロ難τιáo~ 提交于 2019-12-14 03:22:28
问题 We have rightCalloutAccessoryView and leftCalloutAccessoryView for MKPinAnnotationView but is there if we need to add a custom button to the entire popup bubble how to add it the main requirement is i need to perform same action when we tap on Popup bubble just like disclser Button action. //To add a discloser button to show route map inView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; UIButton *detailBtn=[UIButton buttonWithType