简体   繁体   English

在Cordova / Phonegap中使用JavaScript的Google导航

[英]Google navigation using javascript in Cordova/Phonegap

I am using cordova application of telerik appbuilder based on HTML, javascript and css with Google Maps API v3 developing app for iOS and android. 我正在使用基于HTML,javascript和css的telerik appbuilder的cordova应用程序和适用于iOS和android的Google Maps API v3开发应用程序。 I have 2 points A and B each having different latitude and longitude for which, I am able to show a path to move from A to B on map using Google API. 我有两个点A和B,分别具有不同的纬度和经度,我可以使用Google API在地图上显示从A到B的路径。

Now I want to do navigation from A to B in the app itself. 现在,我想在应用程序本身中从A导航到B。 I don't want to open the native app for map available in ios or android. 我不想为ios或android中可用的地图打开本机应用程序。

I don't know how can I do this navigation from A to B? 我不知道如何从A导航到B? As its a real time app which will show my current location. 作为其实时应用程序,它将显示我当前的位置。 For navigation it will show my current location starting from A and will move according to my current location up to B. 为了进行导航,它将显示我的当前位置,从A开始,并将根据我的当前位置移动到B。

Hope someone can let me know any good solution. 希望有人能让我知道任何好的解决方案。

I don't understand why you wouldn't want to use the native navigation app to do the navigating. 我不明白为什么您不想使用本机导航应用程序进行导航。 To do this within your own app, you will have to effectively write your own version of Google Navigator/Apple Maps and embed it within your app, because there's no mechanism by which the native navigation app functionality can be embedded inside your app. 要在自己的应用程序中执行此操作,您将必须有效编写自己的Google Navigator / Apple Maps版本并将其嵌入到您的应用程序中,因为没有机制可以将本机导航应用程序功能嵌入到您的应用程序中。

It's a much easier solution to pass location A & B to the native navigation app - this cordova/phonegap plugin will allow you to do this. 这是将位置A和B传递到本地导航应用程序的简便得多的解决方案- 这个cordova / phonegap插件将允许您执行此操作。

Another alternative is to display the navigation directions using the google maps website in the cordova child browser; 另一种选择是使用Cordova子浏览器中的google maps网站显示导航方向; that way the user isn't leaving your app: 这样,用户不会离开您的应用程序:

window.plugins.ChildBrowser.showWebPage('https://www.google.com/maps?saddr=' + latA + ',' + lonA + '&daddr=' + latB + ',' + lonB + '', {
    showLocationBar: true
});

Thanks for the reply. 谢谢回复。

I have implemented the navigation using the given link below- https://github.com/dpa99c/phonegap-launch-navigator/ 我已经使用下面的给定链接实现了导航-https: //github.com/dpa99c/phonegap-launch-navigator/

I have given the code as shown below for this. 我已经给出了如下所示的代码。

                launchnavigator.navigate("aSourceAddress", "bDestinationAddress",
                function () {
                    alert("plugin success map");
                },
                function (error) {
                    alert("plugin error: " + error);
                },
                {
                    preferGoogleMaps: true,
                    urlScheme: "TestMap2",
                    backButtonText: "TestMap2"
                });

Its switching to google maps app and navigating perfectly. 它切换到谷歌地图应用程序和完美的导航。 But after we reach to destination, it does not come back to our app automatically. 但是,到达目的地后,它不会自动返回到我们的应用程序。

I have also used custom URL plugin as available from- https://github.com/Telerik-Verified-Plugins/Custom-URL-scheme 我还使用了可从以下位置获得的自定义URL插件-https ://github.com/Telerik-Verified-Plugins/Custom-URL-scheme

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM