我正在为 Worklight 应用程序中的地图模块使用 jquery-ui-map V3 插件。我的代码在移动浏览器模拟器中工作。但是当我尝试在 android 设备中运行它时,我无法获取位置。设备上的互联网正在工作,GPS 也已打开。我还在 Android 清单文件中添加了 ACCESS_FINE_LOCATION 权限。这是代码:
<head>
<script type="text/javascript" src="js/Ambit/nearestLocation.js"></script>
<script type="text/javascript" src="jquery.ui.map.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="jquery.ui.map.services.js"></script>
<script type="text/javascript" src="jquery.ui.map.overlays.js"></script>
<script type="text/javascript" src="jquery.ui.map.extensions.js"></script>
</head>
最近位置.js:
$('#FindATM').live("pageshow", function () {
$('#map_canvas').gmap().bind('init', function () {
$('#map_canvas').gmap('getCurrentPosition', function(position, status) {
if ( status === 'OK' ) {
var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
$('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds': true,'zoom': 11});
$('#map_canvas').gmap('addShape', 'Circle', {
'strokeWeight': 0,
'fillColor': "#008595",
'fillOpacity': 0.25,
'center': clientPosition,
'radius': 10,
'clickable': true
});
alert("If block is not executed on Android device. It does on Mobile Browser simulator");
}
});
});
});