Tag: mkannotationview

在拖动过程中查看MKAnnotation坐标

我希望能够跟踪我的MKAnnotation的坐标,当我拖动它。 目前,我只是获取拖动开始时的坐标。 我已经尝试与touchesMoved实现自定义的MKAnnotationView子类,但是这似乎不工作。 (如下所示: 拖动时获取MKAnnotation的坐标 。) 通过拖动我的注释接收新的坐标,我将依次能够更新我的多边形形状。 任何帮助实现这一点将不胜感激,谢谢。

如何在swift中添加彩色边框气泡标注?

我添加了一个右键来标注,但是现在我想为整个泡泡/标注添加一个彩色边框。 比方说,我希望整个泡泡有一个彩色边框。 我想实现的东西作为view?.detailCalloutAccessoryView?.layer.borderWidth = 5.0 view?.detailCalloutAccessoryView?.layer.borderColor = UIColor(red:51/255.0, green:153/255.0, blue:255/255.0, alpha: 1.0).CGColor但它不起作用 类似的东西(我知道在这里他们只看到一个红色的意见),但内部白色,但有一个彩色边框 //MARK: this is for adding info button to pins on map 1/2 func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { var view = mapView.dequeueReusableAnnotationViewWithIdentifier("AnnotationView Id") if view == nil{ view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "AnnotationView Id") view!.canShowCallout = true } else […]

为什么我的注释没有出现在我的地图视图中?

我创build了一套“IssueLocation”,这是一个符合MKAnnotation协议的类。 为什么我的注释(从API JSON数据构build)没有出现在我的地图视图中? 这里是所有背后的代码: class级代码: class IssueLocation: NSObject, MKAnnotation { var locationName: String var campusName: String var latitude: Double var longitude: Double var coordinate: CLLocationCoordinate2D init(locationName: String, campusName: String, latitude: Double, longitude: Double, coordinate: CLLocationCoordinate2D) { self.locationName = locationName self.campusName = campusName self.latitude = latitude self.longitude = longitude self.coordinate = coordinate super.init() } var subtitle: […]

didSelectAnnotationView在将自定义注释添加到mapView时自动调用

我试图在MKMapView上添加自定义的注释,并在注解中实现自定义callOut view 。 我跟这个链接是一样的。 问题是,当我添加自定义注释didSelectAnnotationView被自己调用,并显示popOver callout ,即使用户没有点击注释 这是我的代码: -(void)callAddAnnotationsLocal{ [_mapView removeAnnotations:[_mapView annotations]]; CLLocationCoordinate2D coord = {.latitude = 43.3998170679, .longitude = -95.1288472486}; [_mapView addAnnotations:[self annotationsLocal]]; } -(NSArray *)annotationsLocal{ self.annotArrayLocal = nil; self.annotArrayLocal = [[NSMutableArray alloc] init]; for (int i=0; i<[arrAmmenities count];i++) { MKAnnotationView *propertyAnnotation = [[MKAnnotationView alloc] init]; UIFont *font = [UIFont fontWithName:@"Arial" size:18]; NSDictionary *userAttributes […]

在自定义MKPinAnnotationView中显示注释标题和子标题

我在我的应用程序中使用MKPinAnnotationView 。 我将MapView对象设置为委托,并使用此代码来定制我的AnnotationView func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { //return nil so map view draws "blue dot" for standard user location return nil } let reuseId = "pin" var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView if pinView == nil { pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId) // pinView!.canShowCallout […]

自定义MKAnnotationView触摸区域是可笑的狭窄

我的自定义MKAnnotationView子类不设置它的image属性。 相反,它处理一些子视图来显示。 我在我的委托实现public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)来检测注释触摸。 由于触摸区域默认使用image属性进行计算,所以我的注释视图触摸区域大约为1px。 这是荒唐的。 这是我创build它的方式: init(annotation: JZStreamAnnotation) { self.imageView = UIImageView.init(image: <an image>) self.imageView.contentMode = .center super.init(annotation: annotation, reuseIdentifier: JZStreamAnnotationView.identifier) self.canShowCallout = false self.imageView.center = CGPoint(x: self.frame.width/2, y: self.frame.height/2) self.addSubview(self.imageView) } 我阅读这篇文章 ,但我无法弄清楚hitTest方法是如何工作的。 这里没有做任何事情的实现: override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { if point.x […]

用UIAlertViewStylePlainTextInput编辑注释文本

我可以将引脚标注放到具有泄露button的地图上。 当单击该button时,会popup一个alertView,在其中可以删除选定的注释。 我现在正在尝试使用UIAlertViewStylePlainTextInput编辑选定的注释字幕。 任何想法如何我可以做到这一点? – (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { NSLog(@"Annotation button clicked"); UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Annotation" message:@"Edit Subtitle" delegate:self cancelButtonTitle:@"Hide" otherButtonTitles:@"Update Subtitle", @"Remove Pin",nil]; alert.alertViewStyle = UIAlertViewStylePlainTextInput; [alert show]; } – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) { NSLog(@"Hide button clicked"); } if (buttonIndex == 1) { NSLog(@"Update […]

检测选定的注释以更改引脚颜色

我现在正在做一个mapView。 这是场景: 所有注释都来自JSON对象(MySQL表)。 注释按源表分组: 表1-> Ofertas,表2-> Cursos,表3-> Eventos。 最初显示的地图区域足够大,以后可以显示所有的注释。 有一个UISegmentedControll让用户select应该显示哪个注释组。 在这个应用程序状态下,我将需要进行以下更新: 每个注释组应该具有不同的引脚颜色。 这是我正在使用的方法来绘制注释到mapView取决于所选的索引: – (IBAction)changeOpcion:(id)sender{ if(miControl.selectedSegmentIndex == 0) { //[mapView_ clear]; [self removeAllPinsButUserLocation2]; NSLog(@"********0"); for ( int i=0;i<[categorias count];i++){ int grupo = [[[categorias objectAtIndex:i] objectForKey:@"procedencia"] integerValue]; if (grupo == 1){ double latitud = [[[categorias objectAtIndex:i] objectForKey:@"latitud"] doubleValue]; double longitud = [[[categorias objectAtIndex:i] objectForKey:@"longitud"]doubleValue]; CLLocationCoordinate2D lugar; […]

在MKMapView放大后,MKPinAnnotationView失去pinColor

我有一个MKMapView有很多从parsing器xml定义的注释引脚; 那是我的代码: -(IBAction)LoadAnnotation:(id)sender { RXML element … RXML iterate…. [myMap removeAnnotations:myMap.annotations]; annotation.title = // NSString from RXML parser annotation.subtitle = // NSString from RXML parser myValue = // float value from RXML parser [mymap addAnnotation:annotation]; } 接着 – (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation2 { MKPinAnnotationView *pinView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation2 reuseIdentifier:@"MyPin"]; if ( myValue > […]

为什么在这个IOS代码中仍然会出现双击?

背景 – 我有一个标注(自定义视图添加到注释视图)的地图(MapKit) – 我已经设法确保在标注视图上做出的“长按”手势没有被拾取(见下面,使用“ shouldReceiveTouch“) 问题我不能做的是同样的事情(即忽略)在标注视图上双击,因为MapKit地图仍然以某种方式挑选并放大。我试着把双击手势放到陷阱它,但它似乎并没有工作。 Mapkit视图委托代码 手势识别器的设置 // Gesture Recogniser (Long Press) let longPressGR = UILongPressGestureRecognizer(target: self, action: "longPressAction:") longPressGR.minimumPressDuration = 1 longPressGR.delegate = self self.mapView.addGestureRecognizer(longPressGR) // Gesture Recogniser (Double Tap) let doubleTapGR = UITapGestureRecognizer(target: self, action: "doubleTapAction:") doubleTapGR.numberOfTapsRequired = 2 doubleTapGR.delegate = self self.mapView.addGestureRecognizer(doubleTapGR) 为UIGestureRecognizerDelegate实现“shouldReceiveTouch” extension GCMapViewHelper : UIGestureRecognizerDelegate { func gestureRecognizer(gestureRecognizer: […]