How to open maps App programmatically with coordinates in swift?

前端 未结 9 2331
忘了有多久
忘了有多久 2020-11-30 18:40

I have latitude and longitude that I want to open into my map application. I tried this code from HERE.

    func goToMap(){

    var lat1 : NSString = self.v         


        
9条回答
  •  孤街浪徒
    2020-11-30 19:20

    You can use below code to show PIN on lat, long in to Apple map.

    let coordinates = CLLocationCoordinate2DMake(-37.848854,144.990295)
    
    let regionSpan =   MKCoordinateRegionMakeWithDistance(coordinates, 1000, 1000)
    
    let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
    
    let mapItem = MKMapItem(placemark: placemark)
    
    mapItem.name = “Desired place”
    
    mapItem.openInMaps(launchOptions:[
    MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center)
    ] as [String : Any])
    

提交回复
热议问题