mkannotationview

How to resize MKAnnotationView on iOS6?

泪湿孤枕 提交于 2019-11-29 16:10:13
问题 Resize MKAnnotationView Image When map zooms in and out? This methord are successful on iOS5, but failed on iOS6. I change the MKAnnotationView's transform directly, and no luck. The MKAnnotationView only resize in a flash(When touch up inside the MKMapView, after the touch up finish, the MKAnnotationView will restore the original size). My code are below: - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated { for (id <MKAnnotation>annotation in _mapView.annotations) {

MKAnnotationView always shows infoButton instead of detailDisclosure btn

久未见 提交于 2019-11-29 15:03:19
has somebody an idea why i can't force the mapView callout to use a detailDisclosureBtn instead of infoButton? - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { static NSString *identifier = @"HPIPAnnotation"; if ([annotation isKindOfClass:[CoreCityAnnotation class]]) { MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (annotationView == nil) { annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; } else {

How to access to an annotation attribute inside method calloutAccessoryControlTapped

穿精又带淫゛_ 提交于 2019-11-29 12:46:40
I am trying to open a detail viewController when a user taps on the callout from a map annotation. I have created a custom annotation subclass called myAnnotation, and there I have included a property called idEmpresa. At a custom method I am declaring the annotation as follows: double latitud = [[[categorias objectAtIndex:i] objectForKey:@"latitud"] doubleValue]; double longitud = [[[categorias objectAtIndex:i] objectForKey:@"longitud"]doubleValue]; CLLocationCoordinate2D lugar; lugar.latitude = latitud; lugar.longitude = longitud; NSString *nombre = [[categorias objectAtIndex:i] objectForKey

MKMapView MKPointAnnotation tap event not called

白昼怎懂夜的黑 提交于 2019-11-29 11:42:13
I am using a MKMapView (delegate is set correctly) with a MKPointAnnotation. The annotations are generated in this method called on a background thread. func updateMapAnnotations() { for var i = 0; i < DataManager.getStationList().count; i++ { var s = DataManager.getStationList()[i] as Station var annotation = MKPointAnnotation() annotation.setCoordinate(CLLocationCoordinate2D(latitude: s.latitude, longitude: s.longitude)) annotation.title = "\(s.id)" dispatch_async(dispatch_get_main_queue(), { self.mapView.addAnnotation(annotation) }) } } The annotationViews are generated in here: func

viewForAnnotation confusion and customizing the pinColor iteratively

匆匆过客 提交于 2019-11-29 07:36:29
The goal is to customize the pin colors per some values stored in an structure array. Per some help here I implemented the the following viewForAnnotation delegate method and that works great calling this delegate method iteratively in a loop based on the size of my structure data array. So it works if I want to set all the pins to one color, purple for example (which is the commented line in the code below). The problem is when I put in a switch to set the color based on a value in my array it goes through this code but does not respect any of the case values to set it to an alternate color

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

不问归期 提交于 2019-11-28 18:50:05
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 MeLikeSingleton or whatever observer object you have there: - (void)observeValueForKeyPath:(NSString *

After JSON parsing -viewForAnnotation shows only ONE single annotation on MKMapView

萝らか妹 提交于 2019-11-28 14:23:23
I need to show on my MkMapView about 10 locations (and respective annotations) and after pressing a button I need to add new different annotations according to different JSON parsing results (for example a locationIDValue < 100 means a red pin, otherwise green). This is the simplified code: - (void)viewDidLoad { [super viewDidLoad]; map.showsUserLocation = true; map.mapType = MKMapTypeStandard; arrayID = [[NSMutableArray alloc] initWithObjects: @"id1", @"id2", @"id3", @"id4", @"id5", @"id6", @"id7", @"id8", @"id9", @"id10", nil]; #define MakeLocation(lat,lon) [[CLLocation alloc]

MKAnnotationView and tap detection

旧时模样 提交于 2019-11-28 09:20:46
I have a MKMapView . I added a UITapGestureRecognizer with a single tap. I now want to add a MKAnnotationView to the map. I can tap the annotation and mapView:mapView didSelectAnnotationView:view fires (which is where I'll add additional logic to display a UIView). The issue is now when I tap the annotation, the MKMapView tap gesture also fires. Can I set it so if I tap the annotation, it only responds? There might be a better and cleaner solution but one way to do the trick is exploiting hitTest:withEvent: in the tap gesture recognized selector, e.g. suppose you have added a tap gesture

MKAnnotationView always shows infoButton instead of detailDisclosure btn

给你一囗甜甜゛ 提交于 2019-11-28 08:23:22
问题 has somebody an idea why i can't force the mapView callout to use a detailDisclosureBtn instead of infoButton? - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { static NSString *identifier = @"HPIPAnnotation"; if ([annotation isKindOfClass:[CoreCityAnnotation class]]) { MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (annotationView == nil) { annotationView =

Animate removal of annotations

ⅰ亾dé卋堺 提交于 2019-11-28 07:39:23
I have a map and a set of annotations, each with a 'parent' property. Currently when I add annotations I implement the didAddAnnotationViews method to animate those annotations so they appear to come from their parent's coordinate. Is there a way of doing this during the removal of annotations? When I remove an annotation from the map I want it to animate in to its parent coordinate, and as far as I know there is no equivalent for didAddAnnotationViews for when an annotation is removed. Animate annotation before you remove it from the map and perform removal after animation is completed. The