How to open maps App programmatically with coordinates in swift?

前端 未结 9 2294
忘了有多久
忘了有多久 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:28

    Update to the practical Daniel Saidi answer. This example is for telling only the destination coordinates. Maps will get as origin the user current position.

    let url = URL(string: "http://maps.apple.com/maps?saddr=&daddr=\(lat),\(lon)")
    UIApplication.shared.open(url!)
    
    

提交回复
热议问题