Tag: mkannotationview

在MKMapView上旋转注解图像

我想旋转一个图像,添加到MKMapView作为注释。 这是代码: -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation { if (! [annotation isKindOfClass:[IGAMapAnnotation class]]) { //return default view if annotation is NOT of type IGAMapAnnotation… return nil; } MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"IGAMapAnnotation"]; if (annotationView == nil) { annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"IGAMapAnnotation"]; annotationView.enabled = YES; annotationView.canShowCallout = YES; annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; } else […]

在移动mapview之后显示标注

我在mapview上有几个注释。 select其中一个(启用了标注)之后,我希望地图以它为中心。 我调用[mapView setCenterCoordinate:coordinate animated:YES]; 在didSelectAnnotationView中实现这一点。 它的工作原理并不总是 – 基本上当没有足够的空间来显示标注时,地图会移动并select标注,但标注不会显示(如果移动是animation,则无关紧要)。 如果我不用setCenterCoordinate自己移动地图,在select一个注释之后,地图会自动移动(只是略微)来显示标注,并且每次都有效。 任何想法如何使它在我的情况下工作? 总结一下,我想把地图放在选定的注释上并显示标注。

为什么我的地图视图标注半透明/透明,如何更改颜色?

我在iOS 7上,我有以下问题。 好奇的研究后我找不到线索 我有左和右附件的地图视图注释,但在中间透明(我认为默认的iOS 7行为)。 如何将默认的半透明/透明背景更改为我想要的任何其他颜色?

IOS:将图像添加到自定义MKAnnotationview

我想将自定义图像添加到地图中的注释中。 我做了以下自定义MapAnnotationView: #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import <CoreLocation/CoreLocation.h> @class POI; @interface MapAnnotation : MKAnnotationView <MKAnnotation > @property (nonatomic) CGFloat lat; @property (nonatomic) CGFloat lon; @property (nonatomic) CGFloat altitude; @property (nonatomic, copy) NSString * title; @property (nonatomic, copy) NSString * subtitle; @property (nonatomic,retain) NSString *source; @property (nonatomic,retain) UIImage *image; @end @implementation MapAnnotation @synthesize coordinate; […]

缩放后MKMapview注解dynamicpin图像发生变化

我正在研究一个在地图上显示7种不同types的注释的小项目。 我的注释取自数组中的url结果,并使用JSONparsing。 我有很多的注释,一旦地图加载,一切似乎都很好看。 在放大和缩小之后,针图像由于某种原因而改变为错误的针图像(具体图像,不知道为什么)。 我相信我在这里失去了一些东西…你可以请帮助:)? 这里是我的代码的一部分,让我知道如果你需要它了: -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ static NSString *identifier; if(_mapView.tag==1){identifier = @"TurbulencePin";} if(_mapView.tag==2){identifier = @"IcingPin";} if(_mapView.tag==3){identifier = @"WindsPin";} if(_mapView.tag==4){identifier = @"TemperaturePin";} if(_mapView.tag==5){identifier = @"CloudsPin";} if(_mapView.tag==6){identifier = @"VisibilityPin";} if(_mapView.tag==7){identifier = @"MultiplePin";} if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; if ([annotation isKindOfClass:[Annotation class]]) { CustomAnnotationView* annotationView = (CustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; annotationView = nil; if (annotationView […]

iOS刷新mapview上的注释

我有一个mapview,其注释的坐标不断更新,但是当我使用setCoordinate时,注释不会移动。 如何刷新注释以反映其坐标? – (void)updateUnits { PFQuery *query = [PFQuery queryWithClassName:@"devices"]; [query whereKeyExists:@"location"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { for (PFObject *row in objects) { PFGeoPoint *geoPoint = [row objectForKey:@"location"]; CLLocationCoordinate2D coord = { geoPoint.latitude, geoPoint.longitude }; for (id<MKAnnotation> ann in mapView.annotations) { if ([ann.title isEqualToString:[row objectForKey:@"deviceid"]]) { [ann setCoordinate:coord]; NSLog(@"latitude is: %f" […]

MapView Pin注解的问题 – 当地图放大/平移/区域改变时,Pin会丢失颜色

我有一个mapview显示现金点的位置。 注释被删除,可以点击标注进入一个页面,有关该位置的更多细节。 有两类自由点,免费和付费,免费的自动提款机插针是绿色的,另一个是红色的。 当引脚下降时,它们是正确的颜色。 一切正常,直到我缩放到用户的位置或地图的其他领域,然后当我回到他们已经失去了他们的颜色格式的引脚,都是原来的红色。 我认为这是地图重新加载时,下载瓷砖,而不是正确地重新加载引脚,但我可能是错的。 任何帮助都感激不尽。 这里是我的代码: #import "CashPointMapViewController.h" #import "PinDrop.h" #import "CashPointDetailViewController.h" @implementation CashPointMapViewController @synthesize app, theCashList, mapview, ann, count, myArray, pinColor; – (IBAction) getlocation { MKCoordinateRegion region; region.center = self.mapview.userLocation.coordinate; region.span.longitudeDelta = 0.01f; region.span.longitudeDelta = 0.01f; [mapview setRegion:region animated:YES]; } – (void)viewDidLoad { [super viewDidLoad]; mapview.showsUserLocation = YES; [mapview setMapType:MKMapTypeStandard]; [mapview setZoomEnabled:YES]; […]

如何停止viewForAnnotation方法覆盖iOS中的默认用户位置蓝色信标

现在,我使用注释填充地图视图,并显示用户的当前位置。 使用viewForAnnotation方法,它会覆盖所有注释与默认的红色别针,但我想返回其他注释的意见,但保持用户位置默认的蓝色信标。 有没有办法做到这一点,或者我必须创build一个新的注释视图,并返回正确的取决于注释? 现在我有这样的东西: – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { if (annotation.coordinate == locationManager.location.coordinate) { return nil; }else { MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Beacon"]; // Button UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; button.frame = CGRectMake(0, 0, 23, 23); annotationView.rightCalloutAccessoryView = button; annotationView.canShowCallout = YES; return annotationView; } } 但是我不能将两者等同起来,因为我无法从注解参数中获取坐标属性。 有人知道这个解决scheme吗?

汽车(注释)animation(如超级应用程序)无法正常工作

我做了一个演示项目(从github上的Moving-MKAnnotationView演示)在地图上移动汽车以下是它的链接 https://github.com/pratikbhiyani/Moving-MKAnnotationView 我在vinaut的给定答案的基础上编辑我的代码,但仍然存在的问题是,当我们缩放或滚动地图animation在ios 7和ios 6中获取分散注意力时,我们缩放或滚动地图注释集合到原始angular度一段时间。 下面是我的演示项目的屏幕截图 这是我改变的一些代码 – (void) setPosition : (id) posValue; { NSLog(@"set position"); //extract the mapPoint from this dummy (wrapper) CGPoint struct MKMapPoint mapPoint = *(MKMapPoint*)[(NSValue*)posValue pointerValue]; CLLocationCoordinate2D coord = MKCoordinateForMapPoint(mapPoint); CGPoint toPos; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { toPos = [self.mapView convertCoordinate:coord toPointToView:self.mapView]; } else { CGFloat zoomFactor = […]

如何访问方法calloutAccessoryControlTapped中的注释属性

我想打开一个详细的viewController当用户点击从地图注释的标注。 我创build了一个名为myAnnotation的自定义注解子类,在那里我包含一个名为idEmpresa的属性。 在一个自定义的方法,我宣布注释如下: 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:@"titulo"]; CLLocationCoordinate2D coordinate3; coordinate3.latitude = latitud; coordinate3.longitude = longitud; myAnnotation *annotation3 = [[myAnnotation alloc] initWithCoordinate:coordinate3 title:nombre ]; annotation3.grupo = 1; int number = [[[categorias objectAtIndex:i] objectForKey:@"idObjeto"] […]