Tag: mapkit

iOS Mapkit – 注解在地图滚动/缩放中消失

在初始加载时,注释显示得很好。 但是,如果我滚动地图,它们都消失了,代码只被调用用户位置,而不是viewForAnnotation委托方法中的其他注释。 绘制引脚 -(void)viewDidLoad{ …Download Coordinates and Data from Web here… [self.mapView addAnnotation:pin]; } 委托方法 – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { //Player's Pin if([annotation class] == MKUserLocation.class) { return nil; } //Cluster Pin if([annotation isKindOfClass:[REVClusterPin class]]){ REVClusterPin *pin = (REVClusterPin *)annotation; if( [pin nodeCount] > 0 ){ pin.title = @"___"; MKAnnotationView *annotationView = (REVClusterAnnotationView*)[mapView […]

我的注释不显示PIN中的小标题

在显示PINS的实现类中,我已经预留了两个variables(标题和子标题),在这个例子中,当我点击PIN时,只显示单词USA (标题)。 CLLocationCoordinate2D location2D = (CLLocationCoordinate2D){ .latitude = latitudeOfUserLocation, .longitude = longitudeOfUserLocation }; ManageAnnotations *annotation=[[ManageAnnotations alloc]initWithTitle:@"USA" adresseDuTheme:@"Colorado" coordinate:location2D];//only USA is displayed annotation.pinColor = MKPinAnnotationColorRed; //or red or whatever [self->mapView addAnnotation:annotation]; MKCoordinateSpan span={.latitudeDelta=1,.longitudeDelta=0.5}; MKCoordinateRegion region={location2D,span}; [mapView setRegion:region]; 虽然在ManageAnnotations类中,我已经为标题和副标题保留了两个variables。 @interface ManageAnnotations : NSObject<MKAnnotation>{ NSString *_libelle; NSString *_adresse; CLLocationCoordinate2D _coordinate; } // @property(nonatomic,assign)MKPinAnnotationColor pinColor; @property(copy)NSString *libelle; @property(copy)NSString *adresse; […]

如何放大用户当前的位置?

当应用程序在MapKit中启动时,我想放大用户当前的位置。 这是我的代码(在viewDidLoad函数中): Locate=[[CLLocationManager alloc]init]; Locate.delegate=self; Locate.desiredAccuracy=kCLLocationAccuracyBestForNavigation; Locate.distanceFilter=kCLDistanceFilterNone; [Locate startUpdatingLocation]; [super viewDidLoad]; //Region MKCoordinateRegion myRegion; //Center CLLocationCoordinate2D center; center.latitude=Locate.location.coordinate.latitude; center.longitude=Locate.location.coordinate.longitude; //Span MKCoordinateSpan span; span.latitudeDelta=0.3f; span.longitudeDelta=0.3f; //Set Region myRegion.center=center; myRegion.span=span; [_MyMap setRegion:myRegion animated:YES]; 我也用前面的代码实现了didUpdateLocation函数。 问题是,当用户位置正在改变(当用户正在移动)时,屏幕会放大他,但我不能移动屏幕,如果我尝试移动它立即返回到用户位置,所以我不能看到整个地图。

自定义注释与相同的图像

正如您在下面的图片中看到的,所有注释具有相同的image和discount ,这是不正确的,他们应该有不同的image和discount 。 我怎样才能解决这个问题? 我正在使用一个自定义注释类与discountStr和'imgPathStr'属性和下面的代码。 -(void) connectionDidFinishLoading: (NSURLConnection *) connection { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; _adResultDict = [NSJSONSerialization JSONObjectWithData:_adResultData options:kNilOptions error:nil]; NSMutableArray *annoArray = [[NSMutableArray alloc]init]; NSArray *adArray = [[_adResultDict objectForKey:@"result"]objectForKey:@"ads"]; for (int i = 0; i<adArray.count;i++ ) { NSString *latLongStr = [[adArray objectAtIndex:i]objectForKey:@"area_lat_long"]; NSArray *tempLatLongArray =[ latLongStr componentsSeparatedByString:@","]; CLLocationCoordinate2D adPlace; adPlace.latitude = [[tempLatLongArray objectAtIndex:0] […]

Xcode 7.0 beta 6:与VectorKit的问题

我在我的应用程序中使用MapKit。 除了iOS9以外,一切都很好。 我最近下载了Xcode7.0 beta 6,并在iOS9testing版中运行我的项目,在控制台中挂起了以下错误消息: /BuildRoot/Library/Caches/com.apple.xbs/Sources/VectorKit/VectorKit- 1134.11 / GeoCSS / GeoCSS / StyleSheet.cpp:122 STYL Parse:解码错误/BuildRoot/Library/Caches/com.apple.xbs/Sources /VectorKit/VectorKit-1134.11/GeoCSS/GeoCSS/StyleSheet.cpp:99 STYL Parse:此处解码错误 任何人都知道是什么造成这个问题? 谢谢。 更新: 今天检查' Xcode7.0转基因种子 ',问题仍然存在。 任何人面对相同?

为什么在这个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: […]

是否可以为MKMapView上的用户定位销设置一个固定的屏幕位置?

我试图build立一个MKMapView的方式,用户的位置将永远是偏移在视图控制器的右上angular,我将围绕该“块”构build我的用户界面的其余部分。 有没有办法为MKMapView设置一个固定/偏移中心点,例如,引脚始终位于屏幕上的x,y位置? 如果您无法理解我的目标,我可以提供一个草图示例。

Transit MKDirectionsRequest产生空错误Error Domain = MKErrorDomain Code = 5“(null)”

我正在尝试使用MapKit方向请求获取两个坐标之间的公交路线。 当我切换到其他(非过境)types,下面的代码工作,但是当我切换到过渡,它会抛出一个错误,不会出现在苹果的文档中的任何地方。 这两个地点(来源和目的地)都在纽约市,所以肯定有转机路线。 错误信息: Error Domain=MKErrorDomain Code=5 "(null)" 代码片段: override func viewDidLoad() { super.viewDidLoad() let request = MKDirectionsRequest() // Set request parameters request.source = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 40.7127, longitude: -74.0059), addressDictionary: nil)) request.destination = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 40.6761, longitude: -73.9521), addressDictionary: nil)) request.requestsAlternateRoutes = true // Set tranport type parameter (anything other than .Transit works) […]

从视图中删除MKAnnotationView默认标注

我试图阻止 MKMapKit呈现默认的注释标注,当轻击MKMapView上显示的标记, 而不阻止注释的委托调用/交互(见下文)。 – (void)mapView:(MKMapView *)mapView didSelectAnnotation:(MKAnnotationView *)view { // Custom callout initialized & presented here . . . } 我知道你可以完全禁止标注 someAnnotationView.canShowCallout = NO; 或者(更多的是一种冒险的做法) 不设置注释的任何显示参数: // Commenting out string assignments below // someAnnotation.title = @"Hey!"; // someAnnotation.subTitle = @"Aren't I an annoying callout 😛 ?"; 正如其他线程所build议的那样,在注释视图中添加一个子视图确实会为您select的边框添加一个自定义视图(无论您希望如何)。 然而, 问题是添加一个子视图 不会停止显示默认宣传泡泡 如果您禁用了canShowCallout 或者不设置标签,则注释交互会丢失。 如果添加子视图,则会在默认标注下添加。 3注意您可以延迟子视图的添加时间+0.5秒,然后将您的自定义视图添加到标注上方 ,但这是一个糟糕的解决方法,因为您看到默认标注在您的视图之前很好地显示。 […]

用Swift计算ETA

我试图快速计算两个位置之间的估计旅行时间(步行),用户注释。 这是我目前的代码,它不会抛出任何程序崩溃的错误,但只返回“请求ETA时出错” import UIKit import MapKit class LocationObjects: NSObject, MKAnnotation { /*let userView = CLLocation(latitude: mapView.centerCoordinate.latitude, longitude: mapView.centerCoordinate.longitude) let annotationPoint = CLLocation(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude) let distance = userView.distance(from: annotationPoint)*/ var identifier = "bathroom location" var title: String? var coordinate: CLLocationCoordinate2D var distance: Double var phoneNumber: String var addressFinished: String var estimatedTravelTime: String // Request […]