mkmapviewdelegate

How to know annotation index MKMapview ios

删除回忆录丶 提交于 2020-01-17 06:20:52
问题 Hi i have 100 annotations in mapview ontap of one of its annotations i should get annotation index related to that. Does anyone have idea about getting tag number for that? Looking for any delegate method does. 回答1: Found an answer this will return annotation tapped number: - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view { NSUInteger index = [mapView.annotations indexOfObject:view.annotation]; NSLog(@"index no %d",index); } The above code will generate

is there any way of allowing zooming MKMapView only to a specific region, while disabling any other user interaction?

十年热恋 提交于 2020-01-03 16:00:13
问题 I have a swift app with a MapView. These are my settings on story board for the map: Also, in the code I'm doing: let regionRadius: CLLocationDistance = 10000 let initialLocation = CLLocation(latitude: latitude, longitude: longitude) centerMapOnLocation(initialLocation, map: cell.mapView, radius: regionRadius) cell.mapView.scrollEnabled = false cell.mapView.rotateEnabled = false My method centerMapOnLocation centers the map initially on a specific location: func centerMapOnLocation(location:

How to update information on MKPinAnnotationView?

徘徊边缘 提交于 2020-01-03 00:54:11
问题 I've had some past experience using MKMapView and MKPointAnnotation , which I used to put some pin on a map. This time I am trying to go one step further and use MKPinAnnotationView , to write a label along with some of the pins. Unfortunately, it doesn't all work as I expect. Here is what I want to do: I have a map (an MKMapView object) and when I touch it, I put a pin at the touch point, then some computation is performed and this gives me a second point on the map. I put a second pin on

Detecting panning + decelerate of MKMapView

狂风中的少年 提交于 2020-01-02 06:16:13
问题 I'm trying to capture panning and the 'end of scrolling' on an MKMapView. Panning is easy to do with a gesture recognizer. However, MKMapView doesn't seem to implement a UIScrollViewDelegate in iOS 6. That makes the solution in Is there way to limit MKMapView maximum zoom level? not work. Thoughts? Ideally I would have just leveraged the UIScrollViewDelegate as such: -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { if ([super respondsToSelector:@selector

Is this a bug with MKMapKitDelegate mapView:didUpdateUserLocation?

笑着哭i 提交于 2019-12-28 18:04:12
问题 I've created a test application with only one view containing an MKMapView and a controller which acts as the MapView's delegate. When I do a fresh build (removed from the device completely before re-installing) and log the callbacks, I can see that mapView:didUpdateUserLocation is called twice before the user has indicated whether they wish to show their current location or not. The MKUserLocation objects passed to the callback are invalid: 2012-03-13 08:20:17.518 MapTest[3325:707] Did

Swift 2 MKMapViewDelegate rendererForOverlay compiler warning

余生颓废 提交于 2019-12-23 09:32:48
问题 I am trying to draw a polyline on a map in Swift 2. It all works well, but I get a compiler warning for this code: func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! { if overlay is MKPolyline { let polylineRenderer = MKPolylineRenderer(overlay: overlay) polylineRenderer.strokeColor = UIColor.redColor() polylineRenderer.lineWidth = 5 return polylineRenderer } return nil } This will give me a warning says that ' Result and parameters in mapView

mapViewDidFinishLoadingMap: called too early

偶尔善良 提交于 2019-12-22 05:21:59
问题 My problem is simple: I'm waiting to take a screenshot of an MKMapView, and I want to do it only once the map is loaded. Unfortunately, this delegate method is almost always called before the map is actually loaded. I just get a grid, or a few loaded tiles if I'm lucky. Is there a good way to do what I need to do? Or am I missing something in the MKMapViewDelegate protocol? Thanks! 回答1: Perhaps you could try adding a timer and then take the screenshot in the completion block of the timer. Or

mapViewDidFinishLoadingMap: called too early

白昼怎懂夜的黑 提交于 2019-12-22 05:21:19
问题 My problem is simple: I'm waiting to take a screenshot of an MKMapView, and I want to do it only once the map is loaded. Unfortunately, this delegate method is almost always called before the map is actually loaded. I just get a grid, or a few loaded tiles if I'm lucky. Is there a good way to do what I need to do? Or am I missing something in the MKMapViewDelegate protocol? Thanks! 回答1: Perhaps you could try adding a timer and then take the screenshot in the completion block of the timer. Or

Why is my MKPointAnnotation not Custom?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 05:06:41
问题 My MKPointAnnotation should with this code be custom: -(MKPointAnnotation*)setAnnotation: (NSString*) title atLocation:(CLLocationCoordinate2D)Location withImage:(UIImage*) LocationImage{ Pin = [[MKPointAnnotation alloc] init]; Pin.title = title; [Pin setCoordinate:Location]; [self mapView:mapView viewForAnnotation:Pin].annotation = Pin; return Pin; } -(MKAnnotationView *)mapView: (MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>) annotation{ MKPinAnnotationView* pinView =

MKMapView Clicking on pins won't call didSelectAnnotationView

点点圈 提交于 2019-12-18 08:31:22
问题 I am using a mapView and am trying to make a callout pop up when you click on a pin which is shown on the map. The pins manage to be placed in the proper locations so I think the annotations work but when I click on the pin it won't show a callout. I have show callout = YES. The method didSelectAnnotationView does not get called at all when I click on the pin. Are there some common problems which may cause this method not to be called? 回答1: If tapping on a pin doesn't show the callout even if