从针脚映射方向

时间:2017-06-05 17:29:12

标签: class mapkit mapkitannotation mkmapitem mkplacemark

我正在创建一个标记应用,用户可以在其中将街头艺术标记为地图。我希望用户能够点击针脚(i)标注按钮并转到Apple地图。

这个功能应该允许这种情况发生但是我得到一个错误"实例成员'坐标'不能用于类型'艺术'" -

func openInMaps(){

    let regionDistance:CLLocationDistance = 1000

    let coordinates = art.coordinate

    let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates!, regionDistance, regionDistance)

    let options = [
        MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center),
        MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span)
    ]

    let placemark = MKPlacemark(coordinate: coordinates!, addressDictionary: nil)

    let mapItem = MKMapItem(placemark: placemark)

    mapItem.name = art.name

    mapItem.openInMaps(launchOptions: options)



    }

这是我的艺术课 -

import Foundation
import FirebaseDatabase
import CoreLocation

class art {

let coordinate: CLLocationCoordinate2D!
var name: String!
var location: String!
var type: String!
var ref: FIRDatabaseReference?


init(snapshot: FIRDataSnapshot) {

    let snapshotValue = snapshot.value as! [String: Any]

    ref = snapshot.ref

    name = snapshotValue["name"] as! String

    location = snapshotValue["location"] as! String

    coordinate = CLLocationCoordinate2D(latitude: snapshotValue["lat"] as! Double, longitude: snapshotValue["lng"] as! Double)

   // type = snapshotValue["type"] as! String

}
}

如果有人指出我正确的方向,或者告诉我,我做的事情是错的,那会很棒!感谢。

0 个答案:

没有答案