'iOS - Google maps not showing all the waypoints added in browser. Working fine in google maps app and browser(with desktop site)

I'm working with an app which needs to pass source, in between waypoints and destination in google maps.

I'm first checking whether google maps app can be opened or not. If yes, I open google maps app, else I open maps with browser.

Below is my code:

func openMaps() {
    if UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!) {
        if let mapsAppURL = URL(string: "comgooglemaps://?saddr=56.6440626,-2.8889821&daddr=53.4796061,-2.2455046+to:54.88716525,-2.92375275+to:53.85386995,-2.2135095&directionsmode=driving") {
            UIApplication.shared.open(mapsAppURL, options: [:], completionHandler: nil)
        }
    } else {
        if let url =  URL(string: "https://www.google.co.in/maps/dir/56.6440626,-2.8889821/54.88716525,-2.92375275/53.85386995,-2.2135095/53.4796061,-2.2455046") {
            let safariCont = SFSafariViewController(url: url)
            self.present(safariCont, animated: true, completion: nil)
        }
    }
}

My problem is:

  • In the above code, there are 2 waypoints.
  • If I open google maps app, all the waypoints are visible.
  • If I open it in safari controller, all the waypoints are visible ONLY IN DESKTOP SITE AND NOT IN MOBILE SITE.

Below are the SS for the reference.

Actual issue while opening in browser. only first 3 coordinates are visible: https://i.stack.imgur.com/ZLv9v.jpg

No issue is there in browser when requesting desktop site: https://i.stack.imgur.com/ZjG7H.jpg https://i.stack.imgur.com/6rTjs.png

No issue in Google maps app: https://i.stack.imgur.com/yktT2.jpg

I don't know whether this issue is for mobile site in browser or issue is there in my code

Thanks!



Solution 1:[1]

I think that Google maps in the mobile browser can only have 2 additional waypoints. It doesn’t allow you to add more manually. If you try setting it up yourself, rather than passing in a route you will find that you are unable to set up any more than 2 additional waypoints.

Here is me me adding a 2nd waypoint. Notice the button in the menu that allows you to add the stop.

enter image description here

Here is me trying to add an additional 3rd waypoint. Notice that the add stop button is no longer available.

enter image description here

I think this is a limitation of the Google maps in the mobile browser as according to documentation for the Google mobile maps app you should be able to add up to 9 additional waypoints

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1