<tfoot id='atvTJ'></tfoot>
      <bdo id='atvTJ'></bdo><ul id='atvTJ'></ul>

    <small id='atvTJ'></small><noframes id='atvTJ'>

      <legend id='atvTJ'><style id='atvTJ'><dir id='atvTJ'><q id='atvTJ'></q></dir></style></legend>
    1. <i id='atvTJ'><tr id='atvTJ'><dt id='atvTJ'><q id='atvTJ'><span id='atvTJ'><b id='atvTJ'><form id='atvTJ'><ins id='atvTJ'></ins><ul id='atvTJ'></ul><sub id='atvTJ'></sub></form><legend id='atvTJ'></legend><bdo id='atvTJ'><pre id='atvTJ'><center id='atvTJ'></center></pre></bdo></b><th id='atvTJ'></th></span></q></dt></tr></i><div id='atvTJ'><tfoot id='atvTJ'></tfoot><dl id='atvTJ'><fieldset id='atvTJ'></fieldset></dl></div>

      Android Phonegap - 如何打开原生谷歌地图应用程序

      时间:2023-09-02
      <i id='mkvcN'><tr id='mkvcN'><dt id='mkvcN'><q id='mkvcN'><span id='mkvcN'><b id='mkvcN'><form id='mkvcN'><ins id='mkvcN'></ins><ul id='mkvcN'></ul><sub id='mkvcN'></sub></form><legend id='mkvcN'></legend><bdo id='mkvcN'><pre id='mkvcN'><center id='mkvcN'></center></pre></bdo></b><th id='mkvcN'></th></span></q></dt></tr></i><div id='mkvcN'><tfoot id='mkvcN'></tfoot><dl id='mkvcN'><fieldset id='mkvcN'></fieldset></dl></div>

      1. <legend id='mkvcN'><style id='mkvcN'><dir id='mkvcN'><q id='mkvcN'></q></dir></style></legend>
      2. <small id='mkvcN'></small><noframes id='mkvcN'>

          <tbody id='mkvcN'></tbody>
          <bdo id='mkvcN'></bdo><ul id='mkvcN'></ul>
          <tfoot id='mkvcN'></tfoot>

                本文介绍了Android Phonegap - 如何打开原生谷歌地图应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在使用 Phonegap 开发一个 Android 应用程序,但无法弄清楚如何打开本地 Google 地图应用程序来显示方向.我通过插入 URL 打开地图没有任何问题,但打开应用程序让我很难过.到目前为止,我只能在iOS平台上找到Phonegap相关的开发建议.

                I'm working on an Android application using Phonegap and am having trouble figuring out how to open the native Google Maps application to display directions. I don't have any issue opening a map by inserting a URL but opening the application has me stumped. So far I have only been able to find Phonegap related suggestions for development on the iOS platform.

                我已将 Google 地图添加到白名单权限,在我的脚本标记中包含正确的 Cordova.js 文件和 google 地图链接,在我的 AndroidManifest.xml 文件中具有正确的权限,包含 Cordova.jar 和 Google Map API我的构建路径,res目录下有Phonegap xml文件夹,我的assets/www目录下有js文件,libs目录下有jar文件.

                I have added Google Maps to the whitelist permissions, am including the correct Cordova.js file and google maps link in my script tag, have the correct permissions in my AndroidManifest.xml file, included Cordova.jar and Google Map API in my build path, have the Phonegap xml folder in the res directory, js file in my assets/www directory, jar file in the libs directory.

                我想要完成的事情:

                What I am trying to accomplish:

                  1. 点击链接后,打开原生谷歌地图应用程序.如果设备上未安装应用程序,请通知用户未安装 Google 地图,必须安装.
                    一个.我已经在检查网络连接并按照应有的方式进行处理.
                  1. When a link is clicked, open the native Google Maps application. If the application is not installed on the device, notify the user that Google Maps is not installed and must be installed.
                    a. I am already checking for network connectivity and handling that as it should be done.

                以下示例在我的 Android 设备上的运行与在 iOS 上的运行方式完全相同,但显然无法打开 Google 地图应用程序的操作.

                The example below works on my Android device exactly the same as it does on iOS but obviously does not open the actions Google Maps application.

                <a> href="http://maps.google.com/maps?q=TD Washington DC"><img src="img/ico_pin.png" />White House</a></a>
                

                第二个示例通过包含结束位置添加到第一个示例,尽管我无法弄清楚如何插入当前位置.最重要的是,它仍然无法打开 Google 地图应用程序.

                The second example adds on to the first by including the end location although I wasn't able to figure out how to insert the current location. Most importantly though, it still doesn't open the Google Maps application.

                <a href="javascript:openMaps('daddr=1600+Pennsylvania+Ave+NW+Washington+DC+20500+USA');"><img src="img/ico_pin.png" />White House</a>
                
                function openMaps(querystring) {
                    var maproot = '';
                    maproot = 'http://maps.google.com/maps?saddr=Current+Location&';
                    window.location = maproot + querystring;
                }
                

                在下面的第三个示例中,我能够在我的应用程序中显示地图.它确实显示了正确的路线(从 A 点到 B 点的俯视图),但再次没有打开实际的 Google Maps 应用程序.

                In the third example below, I'm able to display a map within my application. It does show the correct route (from an overhead view from point A to point B) but again doesn't open the actual Google Maps application.

                <a id="whDirections" href="#mm_directions" onclick="getDirections()">
                                    <img src="img/ico_pin.png" />White House</a>
                
                <div data-role="content">
                    <div class="ui-bar-c ui-corner-all ui-shadow" style="padding: 1em;">
                        <div id="mapdirections_canvas" style="height: 300px;"></div>
                    </div>
                </div>
                
                function getDirections() {
                    var directionsService = new google.maps.DirectionsService();
                    var map;
                    var directionsDisplay = new google.maps.DirectionsRenderer();
                    var mapOptions = {
                        zoom: 9,
                        zoomControl: true,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                    var map = new google.maps.Map(document.getElementById("mapdirections_canvas"), mapOptions);
                    directionsDisplay.setMap(map);
                
                    var myLatLng = new google.maps.LatLng(gmmLat, gmmLong);
                    if (document.getElementById("whDirections")) {
                        var request = {
                            origin: myLatLng,
                        destination: new google.maps.LatLng(38.897096, -77.036545), 
                            travelMode: google.maps.TravelMode.DRIVING
                    };
                    directionsService.route(request, function(result, status) {
                        if (status == google.maps.DirectionsStatus.OK) {
                            directionsDisplay.setDirections(result); 
                        }
                    });
                }
                

                如果有人对此有链接或任何想法,我将非常感谢您的帮助.除了Hello World"应用程序,这是我的第一个移动应用程序.请让我知道我是否遗漏了任何内容,或者我只是做错了.如果需要任何其他信息,请告诉我.

                If anyone has a link or any idea on this, I would really appreciate the help. Other than a 'Hello World' app, this is my first mobile application. Please let me know if I have missed anything or if I am just doing this completely wrong. If any additional information is needed, please let me know.

                提前感谢您的帮助.

                推荐答案

                使用地理:输入 uri.

                Use the geo: type uri.

                <a href="geo:38.897096,-77.036545">open map</a>
                

                用户可以选择打开其设备上安装的任何地图应用程序.

                and the user will get the choice of opening any of the mapping applications installed on their device.

                这篇关于Android Phonegap - 如何打开原生谷歌地图应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:仅限 ACCESS_FINE_LOCATION 权限错误模拟器 下一篇:修复 Cordova Geolocation 请求位置消息

                相关文章

                最新文章

              • <legend id='TGAwR'><style id='TGAwR'><dir id='TGAwR'><q id='TGAwR'></q></dir></style></legend>

                <small id='TGAwR'></small><noframes id='TGAwR'>

                <tfoot id='TGAwR'></tfoot>

              • <i id='TGAwR'><tr id='TGAwR'><dt id='TGAwR'><q id='TGAwR'><span id='TGAwR'><b id='TGAwR'><form id='TGAwR'><ins id='TGAwR'></ins><ul id='TGAwR'></ul><sub id='TGAwR'></sub></form><legend id='TGAwR'></legend><bdo id='TGAwR'><pre id='TGAwR'><center id='TGAwR'></center></pre></bdo></b><th id='TGAwR'></th></span></q></dt></tr></i><div id='TGAwR'><tfoot id='TGAwR'></tfoot><dl id='TGAwR'><fieldset id='TGAwR'></fieldset></dl></div>

                      <bdo id='TGAwR'></bdo><ul id='TGAwR'></ul>