ionic2                
            지리적 위치
        
        
            
    수색…
간단한 사용법
 package.json 에서 종속성을 포함시켜야합니다. 
{
    ...
    "dependencies": {
        ...
        "ionic-native": "^1.3.10",
        ...
    },
    ...
}
위치 정보 사용 :
// custom-component.ts
import {Geolocation} from 'ionic-native';
import template from './custom-component.html';
@Component({
    selector: 'custom-component',
    template: template
})
export class CustomComponent {
    constructor() {
        // get the geolocation through a promise
        Geolocation.getCurrentPosition().then((position:Geoposition)=> {
            console.log(
                position.coords.latitude,
                position.coords.longitude);
        });
    }
}
위치 지켜보기
좀 더 실시간으로 해결하기 위해 Geolocation에서 watchPosition 함수를 사용하여 오류 또는 위치 변경이 발생할 때마다 알릴 수 있습니다. getCurrentPosition와 달리 watchPosition은 Observable을 반환합니다.
import {Geolocation} from 'ionic-native';
import template from './custom-component.html';
@Component({
selector: 'custom-component',
template: template
})
export class CustomComponent {
constructor() {
    // get the geolocation through an observable
        Geolocation.watchPosition(<GeolocationOptions>{
            maximumAge: 5000, // a maximum age of cache is 5 seconds
            timeout: 10000, // time out after 10 seconds
            enableHighAccuracy: true // high accuracy 
        }).subscribe((position) => {
            console.log('Time:' + position.timestamp);
            console.log(
                'Position:' + position.coords.latitude + ',' +
                position.coords.longitude);
            console.log('Direction:' position.coords.heading);
            console.log('Speed:' position.coords.speed);
        });
}
Modified text is an extract of the original Stack Overflow Documentation
        아래 라이선스 CC BY-SA 3.0
        와 제휴하지 않음 Stack Overflow