Tag: mkannotation

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吗?

在地图视图上拖动注释引脚

注释引脚是可拖动的,但我不能将其拖放到目标位置。 问题是我怎么能得到目标位置的坐标,我放弃注释引脚? 任何方法存在? 编辑1: 注释引脚的中心似乎从来没有改变,我放弃任何地方的引脚。 – (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateEnding) { NSLog(@"x is %f", annotationView.center.x); NSLog(@"y is %f", annotationView.center.y); CGPoint dropPoint = CGPointMake(annotationView.center.x, annotationView.center.y); CLLocationCoordinate2D newCoordinate = [self.mapView convertPoint:dropPoint toCoordinateFromView:annotationView.superview]; [annotationView.annotation setCoordinate:newCoordinate]; } } 编辑2: Annotation.h @property (nonatomic,readwrite,assign) CLLocationCoordinate2D coordinate; Annotation.m – (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate { coordinate = newCoordinate; } […]

点击泄漏指示器button后如何去第二个视图控制器

我想从mapview中删除现有的注释。 Scenerio是点击现有的注释标注部分(revealindicatorbutton),它会引导用户到另一个视图控制器,并显示一个button,您可以删除选定的注释。 其实,我正在努力创build完全相同的谷歌地图应用程序,这是我现在挣扎的一部分。 任何帮助,将不胜感激!

自定义注释苹果mapkit

我正在尝试分配两个自定义注释,一个名为“arsenal.png”,一个名为“chelsea.png” 使用苹果mapkit框架,xcode 7。 需要代码帮助来实现自定义的标记。 这里是我的实现文件: // TrucksViewController.m #import "TrucksViewController.h" #import "Annotation.h" @interface TrucksViewController () @end //Wimbledon Coordinates #define WIMB_LATITUDE 51.434783; #define WIMB_LONGITUDE -0.213428; //Stadium Coordinates #define ARSENAL_LATITUDE 51.556899; #define ARSENAL_LONGITUDE -0.106483; #define CHELSEA_LATITUDE 51.481314; #define CHELSEA_LONGITUDE -0.190129; //Span #define THE_SPAN 0.20f; @implementation TrucksViewController @synthesize myMapView; #pragma mark – #pragma mark Initialisation – (id)initWithCoder:(NSCoder *)aDecoder { […]

如何访问方法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"] […]

需要在IOS中添加一个固定的覆盖像在mapview上

我需要创build一个地图视图界面,​​类似于iOS中的OLA驾驶室应用程序。 我真正想要做的是修复mapView的覆盖,并允许用户滚动地图视图。 为了使覆盖层可以固定在用户想要的任何位置,我在iOS和MapKit中search了很多关于覆盖层的信息,但是无法实现。 如果有人可以给我提示,以实现这一点,我将非常感激。 这是屏幕快照 在这里,注释保持不变,您可以将地图视图移到地图视图上,这样,当您停止地图视图时,覆盖图将指向新的位置,停止的位置

Swift – 自定义MKAnnotationView,设置标签标题

我正在尝试为我的mapView标注气泡自定义MKAnnotationView。 我可以在创build注解时设置注解标题,还可以自定义MKAnnotationView以添加标签或图像等(在viewForAnnotation委托中),但是如何更改在viewForAnnotation委托中创build的标签,以便标题每个引脚是不同的? 我遇到的另一个问题是,如果在viewDidLoad方法中创build标题或副标题时没有添加标题或副标题,但是我仍然尝试通过离开self.map.addAnnotation(annotation)创build一个标题或副标题,当我运行该应用程序,并点击引脚没有标注泡沫显示。 最后,我想完全定制标注泡泡,每个针脚都有单独的标签。 所以我真正需要知道的是如何在创build注解时访问viewForAnnotation委托来改变每个pin的属性。 override func viewDidLoad() { super.viewDidLoad() var countries: [String] = ["Germany","Germany","Poland","Denmark"] var practiceRoute: [CLLocationCoordinate2D] = [CLLocationCoordinate2DMake(50, 10),CLLocationCoordinate2DMake(52, 9),CLLocationCoordinate2DMake(53, 20),CLLocationCoordinate2DMake(56, 14)] for vari=0; i<practiceRoute.count; i++ { var annotation = MKPointAnnotation annotation.title = countries[i] annotation.coordinate = practiceRoute[i] self.map.addAnnotation(annotation) } } func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { if annotation is MKUserLocation […]

检测点击MKAnnotationView中的CalloutBubble

我正在使用MKMapView和MKAnnotationView。 我在地图上有一个注释。 当用户点击它时,会显示callOut Bubble。 当再次敲击注释(并且callOut Bubble可见)时,我需要切换到另一个视图。 我如何检测第二个水龙头,或在泡沫龙头?