mkmapview

Detect tap on title of callout

一世执手 提交于 2019-12-20 03:02:10
问题 how do I detect a tap on the title of a callout of a annotation? I already have a right callout accessory and a left one, but I want to detect if a user taps on the title (which is in the center on the callout). If this is not possible, how do I disable hiding the callout if I tap on the title? 回答1: it's little late to the answer your question but I'm dealing with same kind of problem recently and make my solution by my self with trial and error. maybe I can help someone who dealing with same

Convert distance on MKMapView to distance for UIView

大兔子大兔子 提交于 2019-12-20 02:59:15
问题 How do I convert distance (for example 400 meters) on MKMapView to distance for UIView? I want to show MKAnnotationView that depends on current zoom level on MKMapView. 回答1: First, create a region with 400 meters length: MKCoordinateRegion myRegion = MKCoordinateRegionMakeWithDistance(mapView.centerCoordinate, 400, 0); After that use convert region methods for getting real rect: CGRect myRect = [mapView convertRegion: myRegion toRectToView: nil]; NSLog(@"width for 400m is %f", myRect.size

MKMapView regionDidChangeAnimated not always called!

假装没事ソ 提交于 2019-12-19 12:53:31
问题 This is frustrating me!!! It will be called most of the time but then it stops responding to the pinches. It will be called on a screen rotate and a double tap. Not to a pinch! Help! 回答1: I was working on some code that had the same issue and turns out the problem was a subview with a UIGestureRecognizer had been added as a subview to MKMapView , and sometimes, they would cause some delegate methods not to fire. So make sure you aren't adding subviews or anything to the MKMapView . Hope this

MKMapView constantly monitor heading

♀尐吖头ヾ 提交于 2019-12-19 11:37:11
问题 I'm rendering some content in a layer that sits on top of my MKMapView . The whole thing works great with the exception of rotation. When a user rotates the map I need to be able to rotate what I'm rendering in my own layer. The standard answer I found is to use: NSLog(@"heading: %f", self.mapView.camera.heading"); The issue with this is that the content of the heading variable only updates when the pinch/rotate gesture is ending, not during the gesture. I need much more frequent updates.

iOS: How to get route path between two coordinates

给你一囗甜甜゛ 提交于 2019-12-19 11:27:29
问题 In my project I've to find out the route path between two locations with the help of latitude and longitude. I'm using the following code for it - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [mapvw setDelegate:self]; [self mapp]; } -(void)mapp { CLLocationCoordinate2D coordinateArray[2]; coordinateArray[0] = CLLocationCoordinate2DMake(28.6129, 77.2295); coordinateArray[1] = CLLocationCoordinate2DMake(28.6562, 77.2410); self

Hiding mapview when mapoverlay is visible ios7

烂漫一生 提交于 2019-12-19 11:27:03
问题 How do I hide the mapview when I have an overlay on top of the mapview in iOS7? This snippet of code used to work in iOS6 but when i upgrade my app to iOS7 it cease to work. NSArray *views = [[[self.mapView subviews] objectAtIndex:0] subviews]; [[views objectAtIndex:0] setHidden:YES]; Any suggestions or feedback? 回答1: With what incanus said with MKTileOverlay , it is like this in the view controller: - (void)viewDidLoad { [super viewDidLoad]; NSString *tileTemplate = @"http://tile.stamen.com

Swift - setting different images from array to annotation pins

爷,独闯天下 提交于 2019-12-19 11:25:17
问题 I wonder how to set different images to annotation pins on mapview. The difference between the following questions viewForAnnotation confusion and customizing the pinColor iteratively Swift different images for Annotation is that my array of images is generated dynamically with regard to server response. There is no fixed size of the array, so switch/case construction is not a good idea. Moreover, I'm not sure how to apply the solution with custom class aforementioned in topic above. I'm

change annotation image after its created

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 07:58:15
问题 I have a custom annotation that sets its image based on the type of the annotation using the viewForAnnotation delegate method. Im only using 1 annotation that represents a car moving and want to change the image for when the car is detected to be moving and stopped. How could I go about this besides removing my annotation and re-adding it which causes a blink? 回答1: Wherever you detect that the car's state has changed, retrieve the annotation's current view using the MKMapView instance method

Map View always center map on my location

谁说我不能喝 提交于 2019-12-19 04:26:12
问题 I use the following code to get my location when a user presses a button [mapview setShowsUserLocation:YES]; and then the follwoing to center the map to te user's location - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { [mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES]; } My question is how to prevent the map from always centering on my location? I want to allow the user to pan the map. 回答1: I think it came in with

Drop pin in center of the screen, MKMapView

爷,独闯天下 提交于 2019-12-19 04:10:59
问题 I have a function that drop pin with this code: ParkPlaceMark *placemark=[[ParkPlaceMark alloc] initWithCoordinate:location]; [mapView addAnnotation:placemark]; How to put this pin on center of the screen? I want something similar to Uber app: http://cl.ly/362q153W461Y1g3X1o04 User is located, dropped is red pin. Then, user can set custom location (in Uber's case, where they want to be picked with taxi cab), and when tap to button to confirm that location. When user setting custom location,