mapkit

Tracking MKMapView centerCoordinate while panning

纵然是瞬间 提交于 2019-11-27 14:31:57
I'm implementing a map feature in my app where I allow the user to set their current location by panning around. All this time, I want to have an MKAnnotation in the centerCoordinate . So what I want to do is keep track of when the map's centerCoordinate changes and change the annotation's coordinate correctly. The behaviour would be similar to that of Uber , Hailo and others. I tried a time based implementation where every 0.00001s the centerCoordinate would be checked and the annotation would also be moved. But if the map isn't flicked gently, the annotation jumps from one place to another

Replace icon pin by text label in annotation?

拈花ヽ惹草 提交于 2019-11-27 14:21:34
Is it possible to replace the pin icon of an annotation by a dynamic text label? Maybe using css, or dynamically creating an image? For example a label is done with CSS on Google Maps API with JavaScript. Yes, it's possible. In iOS MapKit, you'll need to implement the viewForAnnotation delegate method and return an MKAnnotationView with a UILabel added to it. For example: -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; static NSString *reuseId = @"reuseid"; MKAnnotationView *av

MKMapView setRegion “snaps” to predefined zoom levels?

守給你的承諾、 提交于 2019-11-27 14:21:07
Can anyone confirm that setRegion "snaps" to predefined zoom levels and whether or not this behavior is as designed (although undocumented) or a known bug? Specifically, it appears that setRegion snaps to the same zoom levels that correspond to the zoom levels used when the user double-taps the map. I'm trying to restore a previously saved region but this behavior makes it impossible if the saved region was set via a pinch zoom and not a double-tap zoom. A big clue to me that things are broken on the mapkit side is what occurs if I call regionThatFits on the map's current region. It should

Opening native google maps in Xcode

自古美人都是妖i 提交于 2019-11-27 14:16:08
问题 Hi I have an iPhone application using maps and locations. I would like the user to be able to press a button that gives turn by turn directions to that location. I understand that i am not allowed to do this in app, but i was wondering if anyone could tell me if it is possible to make a link to the native google maps application that will enter directions to the location from the users current location. If it is possible could you also tell me how? any help would be appreciated. Thanks 回答1:

Add inverted circle overlay to map view

☆樱花仙子☆ 提交于 2019-11-27 13:11:26
问题 (Using iOS 5 and Xcode 4.2.) I've followed the instructions here: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15 and used the MKCircle and MKCircleView classes to add a circle overlay on my MKMapView. However what I actually want is an inverted circle overlay, like the left map in the sketch below (currently I have a circle overlay like the one on the right): For the

iPhone: Create MKAnnotation

三世轮回 提交于 2019-11-27 12:52:12
Can I create an MKAnnotation , or is it read only? I have coordinates, but I am not finding it easy to manually create an MKAnnotation with using setCoordinate . Ideas? MKAnnotation is a protocol. So you need to write your own annotation object that implements this protocol. So your MyAnnotation header looks like: @interface MyAnnotation : NSObject<MKAnnotation> { CLLocationCoordinate2D coordinate; } @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; // add an init method so you can set the coordinate property on startup - (id) initWithCoordinate:(CLLocationCoordinate2D)coord;

MapKit (MKMapView): zPosition does not work anymore on iOS11

可紊 提交于 2019-11-27 11:41:19
问题 On iOS11 the zPosition stopped working for the annotationView.layer. Every time the map region changes. No luck with original solution: layer.zPosition = X; No luck with bringViewToFront / SendViewToBack methods Xcode 8.3/9 UPDATE (SOLUTION thanks Elias Aalto): When creating MKAnnotationView: annotationView.layer.zPosition = 50; if (IS_OS_11_OR_LATER) { annotationView.layer.name = @"50"; [annotationView.layer addObserver:MeLikeSingleton forKeyPath:@"zPosition" options:0 context:NULL]; } In

Why am I crashing after MKMapView is freed if I'm no longer using it?

人盡茶涼 提交于 2019-11-27 11:35:42
I have a MKMapView . Sometimes after my view controller is dismissed, I'll get a EXC_BAD_ACCESS . I turned on NSSZombies and it looks like the MKMapView 's delegate — my view controller! — is being called, despite both the MKMapView and UIViewController subclass being freed. I've checked, and my memory management is correct. What's going on? This is because of the way MKMapView works. There's an operation pending, so MapKit is retaining the MKMapView and it hasn't actually been deallocated yet. That isn't itself a problem. The problem is that it's still sending messages to your delegate. The

display route on iOS 7 maps: addOverlay has no effect

无人久伴 提交于 2019-11-27 11:17:19
问题 i want display a point to point route inside my mapView, i use this code for create the route: - (IBAction)backToYourCar { MKPlacemark *sourcePlacemark = [[MKPlacemark alloc] initWithCoordinate:self.annotationForCar.coordinate addressDictionary:nil]; NSLog(@"coordiante : locationIniziale %f", sourcePlacemark.coordinate.latitude); MKMapItem *carPosition = [[MKMapItem alloc] initWithPlacemark:sourcePlacemark]; MKMapItem *actualPosition = [MKMapItem mapItemForCurrentLocation]; NSLog(@"coordiante

Swift - CLGeocoder reverseGeocodeLocation completionHandler closure

时间秒杀一切 提交于 2019-11-27 11:14:41
问题 What I'm trying to do is pass a CLLocation to the function getPlacemarkFromLocation which then uses the passed CLLocation through reverseGeocodeLocation to set the CLPlacemark? that will be returned. I'm having issues creating the completionHandler closure in reverseGeocodeLocation , it's throwing a compiler error/crash: In Swift, CLGeocodeCompletionHandler is CLGeocodeCompletionHandler = (AnyObject[]!, NSError!) -> Void according to the documentation AnyObject[]! is supposed to contain