當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Geolocation.getCurrentPosition方法代碼示例

本文整理匯總了TypeScript中@ionic-native/geolocation.Geolocation.getCurrentPosition方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Geolocation.getCurrentPosition方法的具體用法?TypeScript Geolocation.getCurrentPosition怎麽用?TypeScript Geolocation.getCurrentPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ionic-native/geolocation.Geolocation的用法示例。


在下文中一共展示了Geolocation.getCurrentPosition方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

   this.platform.ready().then(() => {
     /* Perform initial geolocation */
     this.geolocation.getCurrentPosition().then((position) => {
         console.log("LAYT :",position.coords.latitude)
     }).catch((err) => {
         console.log('Error getting location', err.message);
     });
 });
開發者ID:NivKapade,項目名稱:ChuzDrApp,代碼行數:8,代碼來源:user-location-popover.ts

示例2: Promise

 return new Promise((resolve, reject) => {
   this.geolocation.getCurrentPosition().then((position) => {
     const latLng: LatLng = new LatLng(position.coords.latitude, position.coords.longitude);
     resolve(latLng);
   }, error => {
     reject(error);
   });
 });
開發者ID:Jefferson227,項目名稱:ionic3-components,代碼行數:8,代碼來源:native-google-maps.ts

示例3: getLocalizacao

 //pegar a localização para salvar a arvore 
 getLocalizacao(){
     debugger
     this.geolocation.getCurrentPosition().then((resp) => {
         // resp.coords.latitude;
         // resp.coords.longitude
     }).catch((error) => {
       console.log('Error getting location', error);
     });
 }
開發者ID:flaviacriss,項目名稱:Verdejarapp,代碼行數:10,代碼來源:newtree.ts

示例4: getLocation

  getLocation(){
    this.geolocation.getCurrentPosition().then(pos =>{
      this.latitude = pos.coords.latitude;
      this.longitude = pos.coords.longitude;
      console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
    });

    let watch = this.geolocation.watchPosition().subscribe(pos =>{
      console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
    });

    watch.unsubscribe();
  }
開發者ID:Jeffsummers2412,項目名稱:camera,代碼行數:13,代碼來源:geolocation.ts

示例5: loadMap

  loadMap(){
    //get the current position device
    this.geolocation.getCurrentPosition().then((position) => {
      let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
 
      let mapOptions = {
        center: latLng,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
      this.addMarker()
    }, (err) => {
      console.log(err);
    });
 
  }
開發者ID:webdesgne,項目名稱:TasksApp,代碼行數:17,代碼來源:maps.ts

示例6: getLocation

 getLocation() {
   this.geolocation.getCurrentPosition().then((resp) => {
     let locationPoint = new BMap.Point(resp.coords.longitude, resp.coords.latitude);
     let convertor = new BMap.Convertor();
     let pointArr = [];
     pointArr.push(locationPoint);
     convertor.translate(pointArr, 1, 5, (data) => {
       if (data.status === 0) {
         let marker = this.marker = new BMap.Marker(data.points[0], { icon: this.myIcon });
         this.map.panTo(data.points[0]);
         marker.setPosition(data.points[0]);
         this.map.addOverlay(marker);
       }
     })
     console.log('GPS定位:您的位置是 ' + resp.coords.longitude + ',' + resp.coords.latitude);
   })
 }
開發者ID:huchun666,項目名稱:Ionic-Maps,代碼行數:17,代碼來源:baidumap.ts

示例7: LocationDisabledError

            .then((isLocationEnabled: boolean) => {
                // GPS disabled
                if (!isLocationEnabled) {

                    /**
                     * Return a Promise<Geoposition> to match next then.
                     *
                     * @see https://github.com/Microsoft/TypeScript/issues/7588#issuecomment-198700729
                     */
                    return Promise.reject<Geoposition>(
                        new LocationDisabledError('Geolocation system disabled.'));
                }

                // Get current location
                return this.geolocationPlugin.getCurrentPosition({
                    enableHighAccuracy: true
                });
            })
開發者ID:blckshrk,項目名稱:vliller,代碼行數:18,代碼來源:location-service-native.ts

示例8: setLocation

 setLocation():void{
   this.geolocation.getCurrentPosition().then((position) => {
     this.latitude = position.coords.latitude;
     this.longitude = position.coords.longitude;
     this.maps.changeMarker(this.latitude, this.longitude);
     let data = {
       latitude : this.latitude,
       longitude : this.longitude
     };
     this.dataService.setLocation(data);
     let alert = this.alertCtrl.create({
       title : 'Location set!',
       subTitle : 'You ca now find your way back to your camp site from anywhere by clicking the button in the top right corner.',
       buttons:[{text:'OK'}]
     });
     alert.present();
   });
 }
開發者ID:qwb0920,項目名稱:build_ionic2_app_chinese,代碼行數:18,代碼來源:location.ts

示例9: ionViewDidLoad

 ionViewDidLoad() {
   console.log('ionViewDidLoad GpsLocationPage');
   this.geolocation.getCurrentPosition().then((resp) => {
     // resp.coords.latitude
     // resp.coords.longitude
     console.log("LAT :",resp.coords.latitude);
     console.log("LOG :",resp.coords.longitude);
    }).catch((error) => {
      console.log('Error getting location', error);
    });
    let watch = this.geolocation.watchPosition();
    watch.subscribe((data) => {
     // data can be a set of coordinates, or an error (if an error occurred).
     // data.coords.latitude
     // data.coords.longitude
     console.log("Data LAT :",data.coords.latitude);
     console.log("Data LOG :",data.coords.longitude);
    });
 }
開發者ID:NivKapade,項目名稱:ChuzDrApp,代碼行數:19,代碼來源:gps-location.ts

示例10: loadMap

    loadMap(){

        this.loading = this.loadingCtrl.create({
            content: 'Attendi...',
        });
        this.loading.present();

        this.geolocation.getCurrentPosition().then((position) => {

            let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

            let mapOptions = {
                center: latLng,
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }

            this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);

            this.addMarkers();

            this.addMyMarker();

            /*let myMarker = new google.maps.Marker({
                map: this.map,
                animation: google.maps.Animation.DROP,
                position: latLng,
            });

            let myContent = "IO";

            this.addInfoWindow(myMarker, myContent);*/

            this.loading.dismiss()
            console.log('fine caricamento mappa')

        }, (err) => {
            console.log(err);

            this.loading.dismiss()
        });

    }
開發者ID:creattico,項目名稱:petrolcompany2,代碼行數:43,代碼來源:mappa.ts


注:本文中的@ionic-native/geolocation.Geolocation.getCurrentPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。