Tag: mkoverlay

在CGPolygonView CGPoint?

我试图找出一种方法来检测哪个MKOverlayView (实际上MKPolygonView )被挖掘,然后改变它的颜色。 我得到它与这个代码运行: – (void)mapTapped:(UITapGestureRecognizer *)recognizer { MKMapView *mapView = (MKMapView *)recognizer.view; MKPolygonView *tappedOverlay = nil; for (id<MKOverlay> overlay in mapView.overlays) { MKPolygonView *view = (MKPolygonView *)[mapView viewForOverlay:overlay]; if (view){ // Get view frame rect in the mapView's coordinate system CGRect viewFrameInMapView = [view.superview convertRect:view.frame toView:mapView]; // Get touch point in the mapView's coordinate […]

检查MKPolyline是否与MKPolygon相交

我试图找出MKPolyline与地图上的MKPolyline相交。 目前我唯一的想法是通过线和testing每一个点,如果它位于多边形。 更确切地说,我试图testingMKUserLocation和map上的目标是否有任何MKPolygon (所以MKUserLocation可以看到这个目标)。 有关如何做到这一点更实际的想法? 如果没有,如何将MKPolyLine转换成很多点?

Objective-C添加MKOverlay来映射视图animation淡入

我一直试图添加一个MKOverlay到animation地图。 我试图使它淡入时,它被删除时淡出。 这可以通过创build一个自定义覆盖类或覆盖视图类来完成?

如何在MapKit中获得可见的覆盖? (即来自Mapkit Ivew的MKOverlay / MKOverlayRender)

如何从MapkitView获取当前可见覆盖的列表(数组)? 背景 – 例如,我想在我的mapkitview上显示方向箭头到某些Overlaytypes的中心,但是如何获得可见的? 似乎没有办法做到这一点,我可以看到? 所以我需要通过所有的覆盖(实际上〜8000),并做我自己的检查,看看会显示在屏幕上? 如果MapKit已经有效地做到了这一点,那么看起来是浪费,因为它决定了在给定的时间内需要显示哪些叠加层。

迅速删除地图叠加

我正试图从地图上删除覆盖。 func removeMapOverlay() { var removeOverlays : [AnyObject]! = self.mapView.overlays // Above line throws runtime exception self.mapView.removeOverlays(removeOverlays) } self.mapView.overlays是AnyObject数组的types。 var overlays: [AnyObject]! { get } var overlays: [AnyObject]! { get } 。 所以最初我写了 var removeOverlays = self.mapView.overlays 它会在运行时在此行抛出EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)exception。 所以我没有为[AnyObject]types转换,我不知道它是正确的,但它仍然给我在运行时相同的exception。 编辑: 我为Objective C代码做的是: – (void) removeMapOverlay { [self.mapView removeOverlays:[self.mapView overlays]]; NSMutableArray *tempArray = [NSMutableArray […]

MKOverlayView性能

我在地图上添加了大约3000个MKOverlay,正如你所想象的那样,有时需要一些时间,大约有八秒。 我正在寻找一种使用线程来提高性能的方法,因此用户可以在添加覆盖图时移动地图。 优选地,叠加层将按顺序添加,从地图区域内的开始。 我已经尝试了一些与GCD有关的事情: – (MKOverlayView*)mapView:(MKMapView*)mapView viewForOverlay:(id)overlay { __block MKPolylineView* polyLineView; //do the heavy lifting (I presume this is the heavy lifting part, but // because this code doesn't compile, I can't actually *test* it) // on a background thread dispatch_async(backgroundQueue, ^ { polyLineView = [[[MKPolylineView alloc] initWithPolyline:overlay] autorelease]; [polyLineView setLineWidth:11.0]; //if the title is […]

如何在mapView更改时刷新MKOverlayRenderer

我是新来的代码,我试图实现像提醒应用程序的东西: 我已经按照另一个答案来实现它 在这里我的代码: 在我的ViewController中: var circle = MKCircle(centerCoordinate: location.coordinate, radius: 100) self.mapView.addOverlay(circle) 在我的MKMapView: func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! { if overlay is MKCircle { render = MapFillRenderer(overlay: overlay) return render } else { return nil } } 而MapFillRenderer(MKOverlayRenderer的子类): class MapFillRenderer: MKOverlayRenderer { var colorIn: UIColor var colorOut: UIColor override func drawMapRect(mapRect: MKMapRect, […]

iOS – MKOverlayView自定义视图矩形填充工程,但线绘制不

新的地图叠加,但这是一个非常奇怪的问题。 我将mapView.visibleMapRect传递给我的覆盖实现,并将其作为boundingMapRect返回,这对于现在很好 – 只是试图在整个地图上绘制一条直线。 我的drawMapRect被调用,并在下面的代码 – 部分透明的绿色矩形绘制,但行不是。 我已经validation了uiview子类的drawRect中的绘图代码,所以我知道它绘制了一些东西:-) 我相信我一定会错过一些简单的东西,但我看不到它:-) 抛出我的是,visibleMapRect在转换为CGRect时有非常奇怪的坐标 – 它们看起来不像我的屏幕坐标 – 这对我来说似乎是问题的根源。 任何帮助将不胜感激: drawMapRect被多次调用,我附加下面的输出。 谢谢,鲍勃 ViewController设置代码: CLLocationCoordinate2D center; center.latitude = 29.46; center.longitude = -98.30; MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta = 0.2; span.longitudeDelta = 0.2; region.center = center; region.span = span; self.mapView.region = region; MyOverlay *myoverlay = [[MyOverlay alloc] initWithCoordinate: center andBoundingRect: self.mapView.visibleMapRect]; [self.mapView […]

自定义MKOverlayRenderer drawMapRect函数不绘制多边形

我已经构build了一个自定义MKOverlayRenderer来构build多边形,应用混合模式,然后将它们添加到地图视图中。 在我的drawMapRect函数中,我使用CGPoint数组来构build多边形,并创build一个path。 但是,在运行时没有任何显示在我的地图视图。 我最好的猜测将是我在drawMapRect函数中创build多边形的顺序。 任何帮助或指导将不胜感激,谢谢! override func drawMapRect(mapRect: MKMapRect, zoomScale: MKZoomScale, inContext context: CGContext) { super.drawMapRect(mapRect, zoomScale: zoomScale, inContext: context) CGContextSaveGState(context) CGContextSetBlendMode(context, CGBlendMode.Exclusion) CGContextSetFillColorWithColor(context, self.fillColor) CGContextSetStrokeColorWithColor(context, UIColor.whiteColor().CGColor) CGContextSetLineWidth(context, 1.0) let point = MKMapPointForCoordinate(self.polygon.points[0]) CGContextMoveToPoint(context, CGFloat(point.x), CGFloat(point.y)) for i in 1..<self.polygon.points.count { let point = polygon.points[i] let p = MKMapPointForCoordinate(point) CGContextAddLineToPoint(context, CGFloat(px), CGFloat(py)) } CGContextClosePath(context) CGContextDrawPath(context, […]

如何:在MKMapView上显示MKOverlay

我需要在地图上显示MKOverlay,但无法实际显示。 我正在关注苹果“ 位置感知编程指南”中的示例 ,并且不会显示覆盖图。 任何帮助将不胜感激,这是我所做的第一个iPhone应用程序,所以我可能会错过简单的东西。 NavViewController.h #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface NavViewController : UIViewController <MKMapViewDelegate> { } @property (weak, nonatomic) IBOutlet MKMapView *mapView; @end NavViewController.m #import "MSUNavViewController.h" #import <CoreLocation/CoreLocation.h> – (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay { if ([overlay isKindOfClass:[MKPolygon class]]) { MKPolygonView* aView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon*)overlay]; aView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:0.2]; aView.strokeColor = [[UIColor […]