我正在使用Phonegap处理一个Android应用程序,但我无法弄清楚如何打开本地Google Maps应用程序来显示方向.我通过插入URL打开地图没有任何问题,但打开应用程序让我感到难过.到目前为止,我只能在iOS平台上找到与Phonegap相关的开发建议.
我已将Google地图添加到白名单权限,包括我脚本标记中的正确Cordova.js文件和google地图链接,在我的AndroidManifest.xml文件中拥有正确的权限,在我的构建路径中包含Cordova.jar和Google Map API ,在res目录中有Phonegap xml文件夹,在我的assets/www目录下有js文件,在libs目录下有jar文件.
我想要完成的事情:
以下示例适用于我的Android设备,与iOS上的相同,但显然无法打开Google Maps应用程序的操作.
<a> href="http://maps.google.com/maps?q=TD Washington DC"><img src="img/ico_pin.png" />White House</a></a>
Run Code Online (Sandbox Code Playgroud)
第二个例子通过包括结束位置来增加第一个例子,尽管我无法弄清楚如何插入当前位置.但最重要的是,它仍然无法打开Google地图应用程序.
<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;
}
Run Code Online (Sandbox Code Playgroud)
在下面的第三个示例中,我可以在应用程序中显示地图.它确实显示了正确的路线(从A点到B点的俯视图),但同样没有打开实际的Google Maps应用程序.
<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 …Run Code Online (Sandbox Code Playgroud)