首页 > 解决方案 > 谷歌地图无法正常打开

问题描述

我正在更新用 VS2010 编写的跨平台应用程序。

我需要提供前往所选地点的驾驶说明。我希望我的应用程序在它自己的窗口中打开谷歌地图(GM),并且已经确定了最佳路线(就像操作员自己打开了 GM 并手动选择了目的地一样)。

我一直遵循 GM 开发人员的说明,但无法让它在 Android 设备上打开 GM,我可以让它在 iOS 上打开 GM,但它挂起(都安装了 GM 并在 Wifi 上)。我没有 Google API 密钥,因为说明说不需要。

IOS:

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

以最后一个目的地打开 GM,但永远处于“加载中……”状态

安卓:

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

这将打开一个选择了推荐路线的网页,但带有“无互联网”横幅。 安卓横幅

当我单击 [导航] 时,系统会询问我是否要使用 Google 地图应用程序。当我单击 [使用应用程序] 时,我收到下面的应用程序错误,导致我进入黑屏,因此我必须重新启动应用程序。顺便说一句,将上面的 url 粘贴到 Android 上的 chrome 中会返回“不匹配任何文档”。

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 ;)

我错过了什么?

从工具栏按钮调用的整个函数完成了以前的尝试:

            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);

    }

标签: google-mapsvisual-studio-2010phonejs

解决方案


推荐阅读