Tag: mapkit

检测一个点是否在MKPolygon覆盖内

我想能够知道是否在一个MKPolygon内水龙头。 我有一个MKPolygon: CLLocationCoordinate2D points[4]; points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116); points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066); points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981); points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267); MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:4]; [self.mapView addOverlay:poly]; //create UIGestureRecognizer to detect a tap UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(foundTap:)]; tapRecognizer.numberOfTapsRequired = 1; tapRecognizer.numberOfTouchesRequired = 1; [self.mapView addGestureRecognizer:tapRecognizer]; 它只是科罗拉多州的基本轮廓。 我得到了龙头/长转换设置: -(IBAction)foundTap:(UITapGestureRecognizer *)recognizer { CGPoint […]

将其添加到地图时使用自定义注释

在将其添加到mapview时,我无法访问自定义注记类。 我有自定义类正常工作,但我当我把它添加到地图我不知道如何通过这个委托访问自定义注释: – (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 我试过在网上找,没有find任何东西。 任何帮助将是伟大的。 它被这样调用: CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(shops.latitude, shops.longitude); AnnotationForId *shop = [[AnnotationForId alloc] initWithCoordinate:coords]; //[[CLLocationCoordinate2DMake(shops.latitude, shops.longtitude)]]; shop.title = shops.name; shop.subtitle = @"Coffee Shop"; shop.shopId = shops.id; [map addAnnotation:shop];

自定义注释苹果mapkit

我正在尝试分配两个自定义注释,一个名为“arsenal.png”,一个名为“chelsea.png” 使用苹果mapkit框架,xcode 7。 需要代码帮助来实现自定义的标记。 这里是我的实现文件: // TrucksViewController.m #import "TrucksViewController.h" #import "Annotation.h" @interface TrucksViewController () @end //Wimbledon Coordinates #define WIMB_LATITUDE 51.434783; #define WIMB_LONGITUDE -0.213428; //Stadium Coordinates #define ARSENAL_LATITUDE 51.556899; #define ARSENAL_LONGITUDE -0.106483; #define CHELSEA_LATITUDE 51.481314; #define CHELSEA_LONGITUDE -0.190129; //Span #define THE_SPAN 0.20f; @implementation TrucksViewController @synthesize myMapView; #pragma mark – #pragma mark Initialisation – (id)initWithCoder:(NSCoder *)aDecoder { […]

在Swift 2.1中用MapKit添加不同的引脚颜色

我是Swift新手。 我试图在特定引脚上使用不同的颜色引脚或自定义引脚。 我的代码工作。 我有一个紫色的针,但我想在他们之间有所作为。 我该怎么做? 我认为有一些在MapView委托方法中做的事情,但我没有find它。 import UIKit import MapKit class MapsViewController: UIViewController , MKMapViewDelegate{ var shops: NSArray? { didSet{ self.loadMaps() } } @IBOutlet weak var map: MKMapView? override func viewDidLoad() { super.viewDidLoad() loadMaps() self.title = "Carte" self.map!.delegate = self } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. […]

iOS MKMapShapshotter完成块并不总是被调用

我正在尝试使用新的iOS7 MKMapSnapshotter生成静态地图图像。 每当我的应用程序需要一张地图,我打电话给以下: MKMapSnapshotter *snapshotter = [[[MKMapSnapshotter alloc] initWithOptions:theOptions] autorelease]; dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); DebugLog(@"Snapshotter allocated %@ and run on queue %@", snapshotter, aQueue); [snapshotter startWithQueue:aQueue completionHandler:^(MKMapSnapshot *snapshot, NSError *error) { DebugLog(@"Snapshotter completion block %@", snapshotter); // perform selector on main thread to set self.imageView.image = shanpshot.image; } 在大多数情况下,这是行之有效的。 然而有时候,这个设备看起来像是超载了地图请求,然后停止了渲染。 在我的日志文件中,我将看到关于“Snapshotter分配”的第一条日志语句,但从来没有看到“Snapshotter completion block”消息。 我的请求可能永远不会从调度队列中执行吗? […]

iOS的MapKit拖动注解(MKAnnotationView)不再与地图平移

我正在学习在我刚刚起步的iOS应用程序中使用MapKit。 我正在使用一些模型实体作为注释(将<MKAnnotation>协议添加到它们的头文件中)。 我也创build自定义MKAnnotationViews并将draggable属性设置为YES 。 我的模型对象有一个location属性,它是一个CLLocation* 。 为了符合<MKAnnotation>协议,我向该对象添加了以下内容: – (CLLocationCoordinate2D) coordinate { return self.location.coordinate; } – (void) setCoordinate:(CLLocationCoordinate2D)newCoordinate { CLLocation* newLocation = [[CLLocation alloc] initWithCoordinate: newCoordinate altitude: self.location.altitude horizontalAccuracy: self.location.horizontalAccuracy verticalAccuracy: self.location.verticalAccuracy timestamp: nil]; self.location = newLocation; } – (NSString*) title { return self.name; } – (NSString*) subtitle { return self.serialID; } 所以,我有4个必要的方法。 而且他们非常简单。 当我阅读MKAnnotationView和@draggable属性中的苹果文档时,它说: 将该属性设置为YES可使用户拖放注释。 […]

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 […]

iOS自定义注释:注释引脚下方的视图

我需要用我的自定义注释视图replace默认的注释视图。 我需要做以下事情: 自定义注释视图中embedded了图像视图。 在它下面的视图中包含一个标签。 要了解更多信息,请参阅图像: 在上面的图片中,我需要在图片视图中放置一个可以在图片中看到的圆形图片,接下来我还需要添加一个包含标签的视图,在该图片上可以设置像我这样的文本,朋友,等等… 所以,为此,我search了堆栈溢出的问题的数目,但没有得到我的答案。 我不想让它出来,我只是想把它作为地图渲染时的注释。 我试图为此做一个自定义的类,但不知道如何处理这个。 任何帮助将不胜感激

使用Swift绘制折线

我想了解如何使用Swift绘制多段线。 我查看了文档,引用了一些教程,并检查了一些其他的SOpost,但我仍然无法在我的地图上画线。 这是我的代码。 有人告诉我我在这里做错了什么? import UIKit import MapKit class FirstViewController: UIViewController { @IBOutlet weak var map: MKMapView! override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) let location = CLLocationCoordinate2D( latitude: -73.761105, longitude: 41.017791 ) let span = MKCoordinateSpanMake(0.07, 0.07) let region = MKCoordinateRegion(center: location, span: span) map.setRegion(region, animated: true) let annotation = MKPointAnnotation() annotation.setCoordinate(location) annotation.title = "White […]

我怎样才能清除MKMapView的地图块的caching?

我正在研究一个基于MKMapView的iPhone / iPad地图应用程序,该应用程序覆盖了我自己的基本地图,即使在用户离线时无法访问Google的地图磁贴服务器,也可以提供一些有限的function。 此function正在工作 – 但我很难在每个新版本之后进行testing,因为我找不到刷新/重置iOS地图切片caching的方法。 iOScaching甚至可以在iOS设备重启和重启的情况下保存下来。 我以前放大的任何地方都会在之前的testing会话中使用内存中的贴图进行渲染。 有没有办法强制iOS刷新其地图caching? 现在我唯一能想到的方法就是每次需要testing的时候刷新操作系统。 谢谢! 顺便说一句:这几乎是这个问题的重复,但在这种情况下,问题不是testing一个空的caching,而是释放内存。 那里给出的答案集中在RAM问题上,而不是我在这里遇到的同样的问题。