标签: mapkitannotation

MapKit注释如何添加详细信息披露信息按钮?

我正在放置annotation一张地图,点击图钉后,detail disclosure info button右边应该有一个,所以我可以在点击按钮后添加更多代码.但是当我运行项目时,点击引脚,没有info button显示出来.任何人都可以提供添加代码disclosure info button吗?

我期待右边的信息按钮: 在此输入图像描述

我的代码:

extension ViewController: MKMapView{


func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {



  }
Run Code Online (Sandbox Code Playgroud)

xcode ios mapkitannotation swift

1
推荐指数
1
解决办法
1652
查看次数

MKMapView只会调用一次didSelect回调

我在自己的mapkit项目中使用了自定义注释(快速3),以在地图上显示多个注释。它正在显示,我只能在第一次单击annotationn。要再次打开注释,我需要在地图上的任意位置单击,然后再次单击注释。有人可以帮助我吗?先感谢您。

这是我正在使用的功能:

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    if annotation is MKUserLocation
    {
        return nil
    }
    var annotationView = self.map.dequeueReusableAnnotationView(withIdentifier: "Pin")
    if annotationView == nil{
        annotationView = AnnotationView(annotation: annotation, reuseIdentifier: "Pin")
        annotationView?.canShowCallout = false
    }else{
        annotationView?.annotation = annotation
    }
    if (indexPin > 0) {
        indexPin = indexPin - 1
        let pin : PinAnnotation = pinAnotationList[indexPin]
        annotationView?.image = UIImage(named: pin.imageName)
    }
    return annotationView
}

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)
{
    if view.annotation is MKUserLocation
    { …
Run Code Online (Sandbox Code Playgroud)

mapkit mkannotation ios mapkitannotation swift

1
推荐指数
1
解决办法
1261
查看次数

将自定义注释添加到MKMapview

我正在尝试添加注释 MKMapView

我创建了一个CustomMapPin符合MKAnnotation协议的类

#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
Run Code Online (Sandbox Code Playgroud)

我创建了一个类CustomMapAnnotationView,它是一个子类MKAnnotationView

CustomMapAnnotationView.h

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface CustomMapAnnotationView : MKAnnotationView
@property (nonatomic, strong) UIImageView *annotationImage;
@end
Run Code Online (Sandbox Code Playgroud)

CustomMapAnnotationView.m

#import "CustomMapAnnotationView.h"

@implementation CustomMapAnnotationView

-(id) initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString …
Run Code Online (Sandbox Code Playgroud)

mapkit mkmapview ios mapkitannotation

0
推荐指数
1
解决办法
3324
查看次数

在 Swift 4 中自动调整缩放以适应 iOS 中的所有标记

我有一个name, lon, 和的字典lat

原始数据

var places = [["name": "Angkor Wat", "lon": "103.8670", "lat": "13.4125"], ["name": "Pick up zone", "lon": "103.85771740610468", "lat": "13.41250067905404"], ["name": "66-35 Otto Rd", "lon": "-73.8889131530723", "lat": "40.706725952864886"], ["name": "40 Williams St", "lon": "-71.30756271909428", "lat": "42.64240728775266"], ["name": "324 Broadway Rd", "lon": "-71.29124543680823", "lat": "42.68061286243683"], ["name": "39 Kendall Pond Rd", "lon": "-71.33234704167283", "lat": "42.867489706954636"], ["name": "269 Treble Cove Rd", "lon": "-71.30049088921143", "lat": "42.55656906569715"]]
Run Code Online (Sandbox Code Playgroud)

列表

在此处输入图片说明

代码

这是我现在拥有的代码。

import UIKit
import MapKit
import CoreLocation

class ViewAllPinsController: …
Run Code Online (Sandbox Code Playgroud)

core-location mapkit ios mapkitannotation swift

0
推荐指数
1
解决办法
1023
查看次数