Tag: mkoverlay

添加倒圆圈叠加到地图视图

(使用iOS 5和Xcode 4.2。) 我按照这里的说明: http : //developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15并使用MKCircle和MKCircleView类在我的MKMapView上添加一个圆形覆盖。 然而,我真正想要的是一个倒圆的覆盖,就像下面的草图中的左侧地图(目前我有一个像右侧的覆盖): 对于倒圆,覆盖层应该覆盖整个地图 – 除了可见的圆。 有没有简单的方法来完成这个使用MKCircle / MKCircleView类? 或者我将不得不深入并定义一个自定义覆盖物体/视图? 感谢您的帮助 :)

animationMKOverlayView

我有一个MKOverlayView,将animation雷达数据显示为一系列图像。 我遇到的问题是,MapKit将雷达图像切成瓦片。 要交换图像我有一个计时器,调用一个更新函数,设置我的覆盖图中的当前图像,然后调用以下内容 [myRadarOverlayView setNeedsDisplayInMapRect:self.mapView.visibleMapRect]; 覆盖更新,但一次一个瓷砖,所以我得到一个波涛汹涌的animation。 任何关于如何使所有的瓷砖animation(即交换图像)在同一时间的想法?

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

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

MKPolylineRenderer产生锯齿状的,不相等的path

我正在使用iOS 7 MapKit API在显示MKDirectionsRequest生成的path的地图上生成3D相机移动。 path由MKOverlayRenderer渲染,如下所示: -(void)showRoute:(MKDirectionsResponse *)response { for (MKRoute *route in response.routes) { [self.map addOverlay:route.polyline level:MKOverlayLevelAboveRoads]; } } – (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay { MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlay:overlay]; UIColor *mapOverlayColor = [UIColor colorWithRed:((float)22 / 255.0f) green:((float)126 / 255.0f) blue:((float)251 / 255.0f) alpha:0.8]; renderer.strokeColor = mapOverlayColor; renderer.lineWidth = 13.0; return […]

自定义MKOverlayView线宽

我有一个自定义的MKOverlayView,它绘制了一个简单的线条。 在drawMapRect:我正在设置CGContextSetLineWidth(context, 30); 完全放大时看起来很好,但当缩小时,线条变得越来越薄。 MKOverlayView引用说它会自动缩放到地图的缩放级别。 无论我的缩放级别如何,我可以强制它绘制相同的宽度? 我注意到,MKPolylineView(和MKPolygonView)正确地做到了这一点…只要你缩放调整以保持相同的宽度,你可以看到线的宽度resize。 我怎么能在我的overlayView中做到这一点?

setNeedsDisplayInMapRect不会触发新的drawMapRect:call

我正在使用自定义的MKOverlay/MKOverlayView来完全覆盖Google自己的MKOverlay/MKOverlayView ,这些MKOverlay/MKOverlayView是asynchronous加载的。 当我收到一个canDrawMapRect:zoomScale:调用我的覆盖视图(并在这种情况下返回FALSE),然后调用setNeedsDisplayInMapRect:zoomScale:一旦该图块可用时,我遵循请求卸载的图块的模式。 这一切通常工作,似乎在模拟器中完美的工作。 但是,在设备上,我有时会在覆盖层上find一个“洞” – 一个缺失的瓷砖。 我可以看到该图块被请求,并且请求完成。 我可以看到我调用了setNeedsDisplayInMapRect:zoomScale: MKMapRect并且传递了MKZoomScale中提供的原始MKMapRect和canDrawMapRect:zoomScale: 但是我也可以看到覆盖层从来没有被要求重绘那个图块( canDrawMapRect:zoomScale:和drawMapRect:zoomScale:inContext:再次被调用该图块)。 我需要了解为什么会发生这种情况,以及如何纠正这种情况。 以下是我的MKOverlayView子类的相关代码: – (BOOL) canDrawMapRect: (MKMapRect) mapRect zoomScale: (MKZoomScale) zoomScale { NSUInteger zoomLevel = [self zoomLevelForZoomScale:zoomScale]; CGPoint mercatorPoint = [self mercatorTileOriginForMapRect:mapRect]; NSUInteger tilex = floor(mercatorPoint.x * [self worldTileWidthForZoomLevel:zoomLevel]); NSUInteger tiley = floor(mercatorPoint.y * [self worldTileWidthForZoomLevel:zoomLevel]); NSURL* tileUrl = [self tileURLForZoomLevel: zoomLevel tileX: tilex […]

在MKMapView上用图案图像画线

我尝试用一​​个模式图像在MKMapView上绘制一条线。 通过添加自定义的MKMapOverlay视图完成绘图。 我能够画出线条,但是似乎只使用了图案图像的左侧最上面的像素,而不是整个图像。 这是我的绘图程序: void drawPatternCellCallback(void *info, CGContextRef cgContext) { UIImage *patternImage = [UIImage imageNamed:@"tmpLine"]; CGContextDrawImage(cgContext, CGRectMake(0, 0, patternImage.size.width, patternImage.size.height), patternImage.CGImage); } – (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { float alpha = 1; float tileW = 6.0f; float tileH = 4.0f; CGFloat lineWidth = MKRoadWidthAtZoomScale(zoomScale)*2; CGMutablePathRef path = CGPathCreateMutable(); if (path != nil) { //setup styles CGContextSetRGBStrokeColor(context, […]

在iOS7中检测MKOverlay的触摸(MKOverlayRenderer)

我有一个可能绘制数百个多边形的MKMapView。 假设在iOS7上使用MKPolygon和MKPolygonRenderer。 我需要的是用户触摸其中一个多边形的方式。 例如,它们代表地图上某个人口密度的地区。 在iOS6上,MKOverlay被绘制为MKOverlayViews,因此触摸检测更直接。 现在使用渲染器,我真的不知道这是怎么做的。 我不确定这会帮助甚至是相关的,但作为参考,我会张贴一些代码: 这使用mapData将所有MKOverlay添加到MKMapView。 -(void)drawPolygons{ self.polygonsInfo = [NSMutableDictionary dictionary]; NSArray *polygons = [self.mapData valueForKeyPath:@"polygons"]; for(NSDictionary *polygonInfo in polygons){ NSArray *polygonPoints = [polygonInfo objectForKey:@"boundary"]; int numberOfPoints = [polygonPoints count]; CLLocationCoordinate2D *coordinates = malloc(numberOfPoints * sizeof(CLLocationCoordinate2D)); for (int i = 0; i < numberOfPoints; i++){ NSDictionary *pointInfo = [polygonPoints objectAtIndex:i]; CLLocationCoordinate2D point; point.latitude […]

有没有办法使用path图添加文本

我有一个从MKOverlayPathViewinheritance的地图自定义视图。 我需要这个自定义视图来显示圆形,线条和文字。 我已经设法使用path绘制CGPathAddArc和CGPathAddLineToPoint函数绘制圆和线。 不过,我仍然需要添加文字。 我试图使用添加文本 [text drawAtPoint:centerPoint withFont:font]; 但我得到了无效的上下文错误。 任何想法?