美好的一天好人,我有一个很好的问题我使用phonegap开发了一个移动应用程序来获取我当前的位置。它在我的笔记本电脑浏览器上工作得很好,但拒绝在我的Android设备上工作。我需要你的帮助。以下是我使用的代码。谢谢
Javascript文件
// JavaScript Document
// When map page is shown, run function
$('#gmap').live("pagecreate", function() {
// Create gmap object, centering on given latitude/longitude, with a terrain map type
$('#map_canvas').gmap({'center': '6.45306, 3.39583', 'mapTypeId': 'terrain'}).bind('init', function(evt, map) {
// Use geolocation function watchPosition() to get position and success/fail status
$('#map_canvas').gmap('watchPosition', function(position, status) {
if ( status === 'OK' ) {
// Set variable 'latlng' to values from watchPosition() function arg 'position'
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
// Set up marker
var markers = $('#map_canvas').gmap('get', 'markers' );
if ( !markers['client'] ) {
$('#map_canvas').gmap('addMarker', { 'id': 'client', 'position': latlng, 'bounds': true });
} else {
markers['client'].setPosition(latlng);
map.panTo(latlng);
}
}
});
});
});
Config.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.ahyoxsoft.eNigeria"
version = "1.0.0">
<name>XXXXXX</name>
<description>xxxxxx</description>
<author href="https://xxxxx.com" email="info@xxxxx.com">
Your Name
</author>
<icon src="images/icon/android/ic_ldpi.png" gap:platform="android" gap:density="ldpi" />
<icon src="images/icon/android/ic_mdpi.png" gap:platform="android" gap:density="mdpi" />
<icon src="images/icon/android/ic_hdpi.png" gap:platform="android" gap:density="hdpi" />
<icon src="images/icon/android/ic_xhdpi.png" gap:platform="android" gap:density="xhdpi" />
<icon src="images/icon/bb/ic.png" gap:platform="blackberry" />
<icon src="images/icon/bb/ic_hover.png" gap:platform="blackberry" gap:state="hover"/>
<icon src="images/icon/webos/ic.png" gap:platform="webos" />
<icon src="images/icon/webos/miniicon.png" gap:platform="webos" gap:role="mini" />
<icon src="images/icon/winphone/ic.png" gap:platform="winphone" />
<icon src="images/icon/winphone/tileicon.png" gap:platform="winphone" gap:role="background" />
</widget>
答案 0 :(得分:0)
将此行放在config.xml
中<access origin="*" />