MLocation¶
MLocation Framework 에 대한 필수 API 를 정의
Location API¶
위치 정보 기능을 제공한다.
위치 정보¶
-
M.
plugin
("location").current( setting)¶ Changed in version 2.1.0.2.
- Arguments
setting (Object) – 위치 정보를 가져오기 위한 설정 정보
setting.timeout (String) – 타임 아웃 (milliseconds)
setting.maximumAge (String) – 최근 위치 정보 여부를 판단하기 위한 델타 값
setting.callback (String) – 위치 정보 반환을 위한 콜백 함수
위치 정보를 가져온다.
- Surrogate Keys: 위 옵션키들과 같은 하위 버전 호환을 위한 대체 옵션 값들
on = callback
Example:
M.plugin("location").current({
timeout: 10000,
maximumAge: 1,
callback: function( result ) {
if ( result.status === 'NS' ) {
console.log('This Location Plugin is not supported');
}
else if ( result.status !== 'SUCCESS' ) {
if ( result.message ) {
console.log( result.status + ":" + result.message );
}
else {
console.log( 'Getting GPS coords is failed' );
}
}
else {
if ( result.coords ) {
console.log( JSON.stringify(result.coords) );
}
else {
console.log( 'It cann\'t get GPS Coords.' );
}
}
}
});