geolocation
getCurrentPosition
현재 위치정보를 읽어온다. 위치정보는 successCallback에 Position객체로 넘어온다.
successCallback
| 필드 | 필드 | 필드 | 설명 |
| result | 위치 상세 정보 | ||
| coords | latitude | 위도 | |
| longitude | 경도 | ||
| altitude | 높이 | ||
| accuracy | 위경도의 정확도(meter법) | ||
| altitudeAccuracy | 높이의 정확도(meter법) | ||
| timestamp | 정보를 수집한 시간 | ||
errorCallback
| 필드 | 설명 |
|---|---|
| 없음 | 없음 |
Example
hone.channel.execute('Geolocation', 'getCurrentPosition', [],
function (result) {
alert("위도:" + result.coords.latitude + ", 경도: " + result.coords.longitude);
}, function (e) {
alert(JSON.stringify(e));
}
);
function (result) {
alert("위도:" + result.coords.latitude + ", 경도: " + result.coords.longitude);
}, function (e) {
alert(JSON.stringify(e));
}
);
Result
{
"coords": {
"accuracy": 18.698999404907227,
"altitude": 0.0,
"altitudeAccuracy": 18.698999404907227,
"latitude": 37.5240917,
"longitude": 126.9229084
},
"timestamp": 1485932041423
}
"coords": {
"accuracy": 18.698999404907227,
"altitude": 0.0,
"altitudeAccuracy": 18.698999404907227,
"latitude": 37.5240917,
"longitude": 126.9229084
},
"timestamp": 1485932041423
}
watchPosition
현재 위치정보를 주기적으로 읽어온다.
options
| 필드 | 설명 |
|---|---|
| interval | 정보 갱신 시간(ms) |
| watchId | watch Id |
successCallback {JSON Object}
| 필드 | 필드 | 필드 | 설명 |
|---|---|---|---|
| result | 위치 상세 정보 | ||
| coords | latitude | 위도 | |
| longitude | 경도 | ||
| altitude | 높이 | ||
| accuracy | 위경도의 정확도(meter법) | ||
| altitudeAccuracy | 높이의 정확도(meter법) | ||
| timestamp | 정보를 수집한 시간 | ||
errorCallback
| 필드 | 설명 |
|---|---|
| 없음 | 없음 |
Example
var interval = 3000;
gpsWatchId = hone.util.getGpsWatchId();
hone.channel.execute('Geolocation', 'watchPosition', [interval, gpsWatchId],
function (result) {
alert("위도:" + result.coords.latitude + ", 경도: " + result.coords.longitude);
}, function (e) {
alert(JSON.stringify(e));
}
);
gpsWatchId = hone.util.getGpsWatchId();
hone.channel.execute('Geolocation', 'watchPosition', [interval, gpsWatchId],
function (result) {
alert("위도:" + result.coords.latitude + ", 경도: " + result.coords.longitude);
}, function (e) {
alert(JSON.stringify(e));
}
);
Result
{
"coords": {
"accuracy": 19.264999389648438,
"altitude": 0.0,
"altitudeAccuracy": 19.264999389648438,
"latitude": 37.5240403,
"longitude": 126.9229504
},
"timestamp": 1485932593408
}
"coords": {
"accuracy": 19.264999389648438,
"altitude": 0.0,
"altitudeAccuracy": 19.264999389648438,
"latitude": 37.5240403,
"longitude": 126.9229504
},
"timestamp": 1485932593408
}
clearWatch
동작중인 watch를 종료한다.
options
| 필드 | 설명 |
|---|---|
| watchId | 동작중인 watchId |
successCallback
| 필드 | 설명 |
|---|---|
| 없음 | 없음 |
errorCallback
| 필드 | 설명 |
|---|---|
| 없음 | 없음 |
Example
var watchId = 1000;
hone.channel.execute('Geolocation', 'clearWatch', [watchId],
function() {
hone.util.clearGpsWatchId(watchId);
alert('success');
}, function(e) {
alert(JSON.stringify(e));
}
);
hone.channel.execute('Geolocation', 'clearWatch', [watchId],
function() {
hone.util.clearGpsWatchId(watchId);
alert('success');
}, function(e) {
alert(JSON.stringify(e));
}
);
