我正在为手机编写Web应用程序,我需要使用地理位置。GPS不工作(Android Web应用程序)
我写道:(JavaScript)的
function GeoLocationStart(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(onSuccess,onError);
}
else{
alert("Functionality not available");
}
}
function onSuccess(position) {
var initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
var userMarker = new google.maps.Marker({
position: initialLocation,
map: map,
title: "You're here",
icon: face
});
userMarker.setMap(map);
var userhtml = "It's you!";
var UserInfoWindow = new google.maps.InfoWindow({content: userhtml});
google.maps.event.addListener(userMarker, 'click', function() {
UserInfoWindow.open(map, userMarker);
});
};
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
它工作正常,但没有GPS。
虽然我在Android清单文件权限设置:
应用程序无法启动,甚至搜索sattelites。 (当然我在我的手机上检查过GPS,它可以在其他应用中使用)
如何开启GPS?
谢谢
+1
如果您使用网络提供我认为它会正常工作。如果使用GPS提供商查找位置转到设置 - >位置和安全并选择使用GPS卫星并取消选中使用无线网络。 –
+0
我在我的手机设置中检查了GPS,它在其他应用程序中可用,但不适用于我的手机。我认为无线网络不会阻止GPS工作。没有他们我的应用程序只是停止显示任何位置和GPS没有出现 –
+0
你在wifi附近运行你的应用程序? –