0

我试图编写代码CLLocationCoordinate2DMake来改变,array所以纬度和经度将根据indxPath......就像我在这里尝试过的那样:

var Longitude = ["32.101145","32.074961","",""]
var Latitude = ["34.775163","34.781679","","",""]


//What i tried :

    let LightHouseLocation = CLLocationCoordinate2DMake(Longitude[indexPath.row],Latitude[indexPath.row])
            // Drop a pin

但当然它会给我带来错误。如果有人可以帮助我,我将不胜感激,谢谢。

4

1 回答 1

0

我就是这样做的。

class ViewController: UIViewController {

    @IBOutlet weak var map: MKMapView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        var coordinates = Array<CLLocationCoordinate2D>()

        coordinates.append(CLLocationCoordinate2DMake(32.101145, 32.074961))

        coordinates.append(CLLocationCoordinate2DMake(34.775163, 34.781679))

        let pins = coordinates.map { (coordinate) -> MKPointAnnotation in

            let pin = MKPointAnnotation()

            pin.coordinate = coordinate

            return pin
        }

        self.map.addAnnotations(pins)
    }
}
于 2017-06-02T06:18:40.583 回答