MapDotNet の Touchgeo ( http://www.mapdotnet.com/index.php/component/content/article?id=131 ) のジオフェンシング機能の watchPosition 関数を作成しています。初期ロードでは、すべてがうまく機能します。更新すると、コールバックが 1 つだけであることを示すデバッグ メッセージが 1 行しか表示されず、携帯電話の 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,
}
);
何か案は?