为什么地图点不显示在 mapKitView 中?
why map points are not displaying in mapKitView?
这里我想在MKMapView中显示倍数位置,但是没有显示
import MapKit
@IBOutlet weak var mapView: MKMapView!
let locations = [
["title": "New York, NY", "latitude": 40.713054, "longitude": -74.007228],
["title": "Los Angeles, CA", "latitude": 34.052238, "longitude": -118.243344],
["title": "Chicago, IL", "latitude": 41.883229, "longitude": -87.632398]
]
override func viewDidLoad()
{
for location in locations {
let annotation = MKPointAnnotation()
annotation.title = location["title"] as? String
annotation.coordinate = CLLocationCoordinate2D(latitude: location["latitude"] as! Double, longitude: location["longitude"] as! Double)
mapView.addAnnotation(annotation)
}
}
我的地图显示的是默认的印度地图。
缩放
mapView.addAnnotation(annotation)
mapView.showAnnotations(mapview.annotations,animated:true)
顺便说一句,想想一个模型
struct Item {
let title:String
let latitude,longitude:Double
}
这里我想在MKMapView中显示倍数位置,但是没有显示
import MapKit
@IBOutlet weak var mapView: MKMapView!
let locations = [
["title": "New York, NY", "latitude": 40.713054, "longitude": -74.007228],
["title": "Los Angeles, CA", "latitude": 34.052238, "longitude": -118.243344],
["title": "Chicago, IL", "latitude": 41.883229, "longitude": -87.632398]
]
override func viewDidLoad()
{
for location in locations {
let annotation = MKPointAnnotation()
annotation.title = location["title"] as? String
annotation.coordinate = CLLocationCoordinate2D(latitude: location["latitude"] as! Double, longitude: location["longitude"] as! Double)
mapView.addAnnotation(annotation)
}
}
我的地图显示的是默认的印度地图。
缩放
mapView.addAnnotation(annotation)
mapView.showAnnotations(mapview.annotations,animated:true)
顺便说一句,想想一个模型
struct Item {
let title:String
let latitude,longitude:Double
}