如何允许用户点击iOS地图以在swift中显示标注?

时间:2022-10-08 21:20:16

I am trying to build an application where I need to show a callout with details regarding business (name, address etc) when user clicks on the points of interests on the map.

我正在尝试构建一个应用程序,当用户点击地图上的兴趣点时,我需要显示一个带有关于业务(名称,地址等)的详细信息的标注。

I am able to show callout when there is an annotation. But I want to have a functionality similar to apple maps application, where even without an annotation, users are able to directly tap on the point of interest to show the details about that point of interest.

我可以在有注释时显示标注。但是我希望有一个类似于apple maps应用程序的功能,即使没有注释,用户也可以直接点击感兴趣的点来显示有关该兴趣点的详细信息。

I have already set the following properties on my mapView:

我已经在mapView上设置了以下属性:

mapView.userInteractionEnabled = true
mapView.showsPointsOfInterest = true

Any help is appreciated.

任何帮助表示赞赏。

1 个解决方案

#1


0  

you can use MKMapViewDelegate and override Mouse Event

您可以使用MKMapViewDelegate并覆盖鼠标事件

override func rightMouseDown(theEvent: NSEvent) {
    let eventLocation: NSPoint = theEvent.locationInWindow
    // do something
    NSNotificationCenter.defaultCenter().postNotification(notification)

}

#1


0  

you can use MKMapViewDelegate and override Mouse Event

您可以使用MKMapViewDelegate并覆盖鼠标事件

override func rightMouseDown(theEvent: NSEvent) {
    let eventLocation: NSPoint = theEvent.locationInWindow
    // do something
    NSNotificationCenter.defaultCenter().postNotification(notification)

}