1

I am updating a cross platform app written in VS2010.

I need to provide driving instructions to the selected location. I would like my app to open Google Maps (GM) in it’s own window with the best route already determined (as if the operator had opened GM themselves and selected the destination manually).

I have been following GM developer’s instructions but cannot get it to open GM on Android device, I can get it to open GM on iOS but it hangs (all have GM installed & on Wifi). I do not have a Google API key as instructions say it’s not needed.

iOS:

    window.open("maps://www.google.com/maps/dir/?api=1&destination=-36.847456,174.830521&travelmode=driving");

Opens GM with last destination but sits on ‘Loading…’ forever

Android:

    window.open("https://www.google.com/maps/dir/?api=1&origin=-36.852946,174.763348&destination=-36.847456,174.830521&travelmode=driving");

This opens a web page with recommended route selected, but with a ‘No internet’ banner. AndroidBanner

When I click [Navigate] I am asked if I want to use Google Maps app. When I click [Use the app] I get the application error below which takes me to a black screen so I must restart the app. As an aside, pasting above url into chrome on Android returns ‘did not match any documents’.

net::ERR_UNKNOWN_URL_SCHEME(intent://maps.app.goo.gl/?link= https://www.google.com/maps/dir//-36.847456,174.830521/@-36.8660726,174.7966977,12z/data%3D!4m2!4m1!3e0!11m1!6b1&apn=com.google.android.apps.maps&amv=914018424&isi=585027354&ibi=com.google.Maps&ius=comgooglemapsurl&utm_campaign=ml_promo&ct=ml-navfab-nlu-o&mt=8&pt=9008#Intent;package=com.google.android.gms;scheme=https;S.browser_fallback_url=https://play.google.com/store/apps/details%3Fid%3Dcom.google.android.apps.maps&pcampaignid%3Dfdl_long&url%3Dhttps://www.google.com/maps/dir//-36.847456,174.830521/@-36.8660726,174.7966977,12z/data%253D!4m2!4m1!3e0!11m1!6b1&min_version%3D914018424;end;)

What am I missing?

Entire function that is called from a toolbar button complete with previous attempts:

            mapsSelector: function () {

        // helpful url: https://developers.google.com/maps/documentation/urls/ios-urlscheme

        var mapURL = "https";
        if /* if we're on iOS, open in Apple Maps */
            ((navigator.platform.indexOf("iPhone") != -1) ||
             (navigator.platform.indexOf("iPad") != -1) ||
             (navigator.platform.indexOf("iPod") != -1))
            mapURL = "maps";

        /*
        mapURL = mapURL + "://www.google.com/maps/dir/" +
             viewModel.Latitude_Now() + "," + viewModel.Longitude_Now() + "/" +
         viewModel.Latitude_Destination() + "," + viewModel.Longitude_Destination() + ",17/" +
                 "am=t";
        mapURL = "http://maps.google.com/maps?saddr=-36.91078,174.850896&daddr=-36.7492041,174.6866052";
        mapURL = "https://www.google.com/maps/dir/?api=1&saddr=-36.91078,174.850896&daddr=-36.7492041,174.6866052";
        mapURL = "https://www.google.com/maps/dir/?api=1&origin=-36.91078,174.850896&destination=-36.7492041,174.6866052&travelmode=driving";
        */


        mapURL = "https://www.google.com/maps/dir/?api=1&origin=-36.852946,174.763348&destination=-36.847456,174.830521&travelmode=driving"; 
        //mapURL = "maps://www.google.com/maps/dir/?api=1&destination=-36.847456,174.830521&travelmode=driving"; 

        alert(mapURL);
        window.open(mapURL);

    }
Muzza
  • 21
  • 3
  • 1
    Hi @Muzza! Welcome to SO! Can you provide some code to show what you've tried? This will help the community assist you. – dst3p Jan 17 '19 at 22:51
  • Hi @dst3p There is not much more to the code, just a function called from a toolbar button. But I have now added the entire function complete with previous attempts to my post. – Muzza Jan 18 '19 at 00:36

0 Answers0