0

I am a Swift/iOS beginner and I want to use Google Maps API to draw direction between to locations, I now how to do this using MapKit but MapKit dose not support directions in Iraq.

Can someone help me get started with Google Maps? I need this for my project.

DoesData
  • 6,594
  • 3
  • 39
  • 62
  • 1
    What have you tried so far? Where is your code? – DoesData Mar 15 '18 at 12:47
  • i don't get any source to . learn detail about it ,i finshed my project with mapkit and at the end i thought that mapkit dosen't suport direction in my country so i saw so many youtube videos but it dose not . help mee – Arwen Ghafur Mar 15 '18 at 12:56

1 Answers1

3

You can use Directly Google map to get the direction from your current location to desire location by using following lines of code

(If you have "Google Map" App in your phone if loop will execute otherwise else loop will execute and open google map on your web browser)

if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
                UIApplication.shared.openURL(NSURL(string:
                    "comgooglemaps://?saddr=&daddr=\(Float((Yourcoordinate.latitude)!)),\(Float((Yourcoordinate.longitude)!))&directionsmode=driving")! as URL)

            } else {

                let url = "https://www.google.co.in/maps/dir/?saddr=&daddr=\(Float((Yourcoordinate.latitude)!)),\(Float((Yourcoordinate.longitude)!))"
                UIApplication.shared.openURL(NSURL(string:url)! as URL)
            }

Hope this will help...

Sachin Amrale
  • 277
  • 1
  • 9
  • thanks a lot thats work but It shows straight lines, i want it to show me the way for example to tell how to get from the source to the destination in a car, not a straight line , how to do this? – Arwen Ghafur Mar 15 '18 at 13:05