Tag: mkoverlay

通过MapKit绘制path问题

我创build了一个不断读取当前用户坐标并将其存储在SQLite数据库中的应用程序。 我有一个显示在整个屏幕上的地图。 现在我想在用户移动时在地图上划一条线。 我已经创造了这一切。 问题是,我不能让它成为一个“活”。 覆盖未更新。 这是逻辑: 在ViewDidLoad我有 … if (nil != self.routeLine) { [self.mapView addOverlay:self.routeLine]; } 在处理每个新坐标的函数中,我有: … NSString* coordinate = [NSString stringWithFormat:@"%f,%f", thisLocation.longitude, thisLocation.latitude]; [self.paths addObject:coordinate]; MKMapPoint northEastPoint; MKMapPoint southWestPoint; // create ac array of points. MKMapPoint* pointArr = malloc(sizeof(CLLocationCoordinate2D) * self.paths.count); for(int idx = 0; idx < self.paths.count; idx++) { // break […]

添加MKOverlayPathRenderer作为覆盖MKMapView获取exception

一切都在主题中说,所以这里是代码 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _pathRenderer = [[MKOverlayPathRenderer alloc] init]; _pathRenderer.lineWidth = 8.0f; _pathRenderer.strokeColor = [UIColor redColor]; _pathRenderer.path = CGPathCreateMutable(); [_mapView addOverlay:_pathRenderer]; } 在最后一行,它会抛出exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKOverlayPathRenderer boundingMapRect]: unrecognized selector 这意味着我使用错误的类,没有实现MKOverlay,我明白了,但正如参考MKOverlayPathRenderer所说 – 它的确如此。 所以我有点卡住了这个问题。

通过networking服务创build多个折线的MKOverlay

我的应用程序是实时跟踪器,多用户login和更新他们的位置,通过发送他们的坐标到我们的Web服务,然后callback,让我们每2分钟后显示所有用户在我的MapView 。 每次我从web服务中获取用户在connectionDidFinishLoading方法中的位置时,我正在parsing,通过pointsArray创build多段polyline并将它们添加到overlay : -(void) connectionDidFinishLoading: (NSURLConnection *) connection { userLatitudeArray = [[NSMutableArray alloc]init]; userLongitudeArray = [[NSMutableArray alloc]init]; userIdArray = [[NSMutableArray alloc]init]; userNameArray = [[NSMutableArray alloc]init]; userProfilePicArray = [[NSMutableArray alloc]init]; profilePicURLStringArray = [[NSMutableArray alloc]init]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; NSArray *trackingDict = [NSJSONSerialization JSONObjectWithData:empJsonData options:kNilOptions error:nil]; if ([trackingDict count] >= 2) { for (trackUsersCount = 0; […]

iOS6上的MapKit的性能问题

在更新到iOS 6之后,我注意到在使用多个叠加层平移或缩放MKMapView时,服务器性能下降。 我创build的应用程序拥有大约600多种不同颜色的多边形覆盖图,并且在iOS 5上运行无延迟(即使是在较旧的iOS设备上),现在在iOS 6上运行极其缓慢(在缩放和平移时),即使在最新的设备上也是如此。 我的直觉是,这是由于设备必须实际dynamic地创build地图(因为其基于vector),而不是仅仅在屏幕上显示瓦片。 有没有人有任何想法,以减less平移或缩放地图时遇到的滞后? 一些额外的信息,这个低帧率也发生在缩放或平移覆盖层不显示在屏幕上的区域,所以它不会在屏幕上创build覆盖层。

寻找一个MKOverlayPathRenderer的例子

我想弄清楚如何使用一个新的MKOverlayPathRenderer类。 在我的应用程序中,我以前在使用iOS 6 SDK进行MKOverlayPathView时使用了MKOverlayPathView ,但不幸的是,它似乎不适用于iOS 7 SDK。 所以我试图将我的应用程序从MKOverlayPathView移动到MKOverlayPathRenderer ,但迄今为止没有成功。 MKPolylineRenderer工作正常,但MKOverlayPathRenderer不。 代码被调用,但是在地图上没有绘制覆盖图。 有没有人有MKOverlayPathRenderer工作的例子?

如何检测MKPolylines /覆盖如Maps.app上的水龙头?

当在iPhone上的内置Maps.app上显示方向时,您可以通过点击来select通常显示的3个path选项之一。 我不想复制这个function,并检查一个水龙头是否在一个给定的MKPolyline。 目前我检测到像这样的MapView的水龙头: // Add Gesture Recognizer to MapView to detect taps UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleMapTap:)]; // we require all gesture recognizer except other single-tap gesture recognizers to fail for (UIGestureRecognizer *gesture in self.gestureRecognizers) { if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) { UITapGestureRecognizer *systemTap = (UITapGestureRecognizer *)gesture; if (systemTap.numberOfTapsRequired > 1) { [tap requireGestureRecognizerToFail:systemTap]; […]

MKMapView – 限制地图滚动到方形覆盖

我有一个MKMapView与方形覆盖描述为: CLLocationCoordinate2D coordsBg[5]={ CLLocationCoordinate2DMake(31.750865,35.180882), CLLocationCoordinate2DMake(31.740331,35.180882), CLLocationCoordinate2DMake(31.740331,35.165452), CLLocationCoordinate2DMake(31.750865,35.165452), CLLocationCoordinate2DMake(31.750865,35.180882) }; MKPolygon *bg=[MKPolygon polygonWithCoordinates:coordsBg count:5]; [map addOverlay:bg]; 我希望限制用户在覆盖之外滚动。 我可以限制MKMapView的滚动视图吗? 或者还有其他方法? 谢谢 沙尼

平滑调整MKCircle

在调整NSSlider时,如何在UIMapView上顺利调整MKCircleView的大小? 在创build地理围栏时,苹果已经在“ 查找我的朋友”应用中做到了这一点,所以我想这是可能的。 到目前为止,我已经尝试了下面的解决scheme,但是有一个非常“闪烁”的结果: 第一次尝试 我添加了一个新的MKCircleView具有更新的半径,并立即删除(当在这里build议MKOverlay不顺利resize )当滑块更改值后。 我也尝试了另一种方式:首先删除覆盖,然后添加一个新的,但具有相同的“flickery”结果。 – (void)sliderChanged:(UISlider*)sender { double radius = (sender.value * 100); [self addCircleWithRadius:radius]; [mapView removeOverlays:[self.mapView.overlays firstObject]]; } 第二次尝试 在链接的SO答案中,他build议NSOperation可以用来“帮助你更快地创buildMKCircle对象”,从而在幻灯片更改值时使用上述添加/删除叠加的方法使调整更平滑。 我做了一个实现,当滑块更改时,我开始一个新的线程。 在每个线程中,我删除所有旧的覆盖,并添加一个新的更新的比例。 也许他还有一些其他的实现方式,因为我做这件事的方式在更改滑块时仍然会有相同的闪烁。 – (void)sliderChanged:(UISlider*)sender { NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(updateOverlayWithScale:) object:[NSNumber numberWithFloat:sender.scale]]; [self.queue addOperation:operation]; } 运行我的每个线程的方法: – (void)updateOverlayWithScale:(NSNumber *)scale { MKCircle *circle = [MKCircle circleWithCenterCoordinate:self.currentMapPin.coordinate radius:100*[scale floatValue]]; […]

如何在MKAnnotations上方显示MKOverlay?

我正在尝试使用MKOverlay (特别是MKPolyline )在地图上显示路线。 但是,我需要显示在我现有的引脚(自定义MKAnnotationView )上方的路线。 有没有一种好方法将MKPolyline放在引脚上方?

MKMapView有多个覆盖内存的问题

似乎有一个覆盖和MapKit的“问题”。 与注释不同的是,叠加层不会被重用,因此添加多个叠加层会导致真实设备上的内存问题。 我有这个问题多次。 所以我的问题是,如何重新使用MKOverlay,从而提高MapKit覆盖层的性能?