【发布时间】:2013-06-07 17:38:24
【问题描述】:
我正在为 MapDotNet 的 Touchgeo (http://www.mapdotnet.com/index.php/component/content/article?id=131) 中的地理围栏功能编写 watchPosition 函数。在初始加载时,一切都运行良好;刷新时,我只收到一行调试消息,表示只有一个回调,而且我手机上的 GPS 永远不会打开。这是我的 watchPosition 函数:
navigator.geolocation.watchPosition(
function success(pos) {
$('#debug')
.prepend(
$('<div></div>').text('accuracy: ' + pos.coords.accuracy)
)
.css({
textAlign: 'right',
color: 'black'
});
var endpoint = isc.touchgeo.dataServicesEndpoint + "Map/mapname/Features/geofence?x={x}&y={y}&role={role}"
.replace("{x}", pos.coords.longitude)
.replace("{y}", pos.coords.latitude)
.replace("{role}", isc.touchgeo.authenticationMgr.getAuthorizationRecord().Role);
$.getJSON(endpoint, function success(data) {
$('#debug')
.prepend(
$('<div></div>').text('features: ' + data.length)
)
.css({
textAlign: 'right',
color: 'black'
});
for (layer in data) {
if (layer in geofencingRules) {
geofencingRules[layer](data[layer]);
}
}
});
},
function error(error) {
$('#debug')
.prepend(
$('<div></div>').text('error: ' + error.code)
)
.css({
textAlign: 'right',
color: 'black'
});
},
{
enableHighAccuracy: true,
maximumAge: 15000,
}
);
有什么想法吗?
【问题讨论】:
标签: android html google-chrome geolocation gps