【发布时间】:2013-08-09 02:08:47
【问题描述】:
我正在尝试获取用户在移动 Web 应用程序中的当前位置
我的应用程序适用于除三星 galaksy s2 电话设备之外的所有 android 电话设备..
它给出错误 POSITION UNAVAILABLE 错误
这是demo链接。你可以查看源代码
这是代码
navigator.geolocation.getCurrentPosition(handle_geolocation_query1, handle_errors) ;
function handle_errors(error) {
switch (error.code) {
case error.PERMISSION_DENIED: alert("user did not share geolocation data");
break;
case error.POSITION_UNAVAILABLE: alert("could not detect current position");
break;
case error.TIMEOUT: alert("retrieving position timed out");
break;
default: alert("unknown error");
break;
}
}
function handle_geolocation_query1(position) {
$('#map_canvas').gmap('addMarker', {
'id':'m_1',
'position': new google.maps.LatLng(position.coords.latitude,position.coords.longitude),
'bounds': true,
'icon': 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/geolocationmarker/images/gpsloc.png'
}).click(function () {
$('#map_canvas').gmap('openInfoWindow',{ 'content': '<font color="#2a2a2a" size="4">Location </font><br/><font color="#4a4a4a">Your current location</font>' }, this);
});
var map = $('#map_canvas').gmap('get', 'map');
map.setZoom(14);
map.setCenter(new google.maps.LatLng(41.01802007732287, 28.971880674362183));
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
}
编辑: 我用phonegap来生成android apk文件 当我使用这个 apk 文件应用程序时,它会给出错误 POSITION UNAVAILABLE 错误,但是当我从 web 调用这个页面时它不会给出错误......这是 web link,您可以从 here 下载 apk
【问题讨论】:
-
看起来您的代码正在按预期工作。
-
在浏览器中可以正常工作...在许多 android 电话设备上可以正常工作..它不能在三星 galaksy s2 电话设备上工作
-
好吧,从地理定位服务返回valid status (
POSITION_UNAVAILABLE) 的意义上说,它正在工作。您是否最终确定您的三星 Galaxy SII 没有问题?尝试其他地理定位服务,看看它是否有效。 -
在我的设备中在我的其他朋友设备中它可以工作..但在我的客户三星 galaksy s2 中它不起作用...它给出 position_unvailable 错误...我该如何解决这个问题?关闭 gps设置??
标签: html google-maps google-maps-api-3 geolocation w3c-geolocation