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


TypeScript Geolocation.getCurrentPosition方法代碼示例

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


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

示例1: GoogleMapsLatLng

    this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
      console.log('Map is ready!');


      console.log(this.lat + ' ' + this.long);

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

        let coord = new GoogleMapsLatLng(this.lat, this.long);
        this.map.setCenter(coord);

        //this.map.animateCamera({
        //  'target': coord,
        //  'tilt': 60,
        //  'zoom': 18,
        //  'bearing': 140
        //});

        this.map.addMarker({
          'position':coord,
          'title': "The TagOn Project HeadQuarters"}).then(marker => {
          marker.addEventListener(GoogleMapsEvent.INFO_CLICK).subscribe(() => {
            console.log("Info window was clicked");
          });
        });
      });
    });
開發者ID:kolexinfos,項目名稱:tag,代碼行數:30,代碼來源:home.ts

示例2: constructor

 constructor(private nav: NavController) {
   Geolocation.getCurrentPosition().then((resp) => {
   console.log(resp.coords);
   //resp.coords.longitude
   })
     
 }
開發者ID:colanconnon,項目名稱:ionicFishTracker2,代碼行數:7,代碼來源:newfishcatch.ts

示例3: acquireLocation

 private acquireLocation() {
   Geolocation.getCurrentPosition().then((resp) => {
     console.log('Coordinates are ' + resp.coords.latitude + ',' + resp.coords.longitude);
     this.submission.latitude = resp.coords.latitude;
     this.submission.longitude = resp.coords.longitude;
   });
 }
開發者ID:codeforcologne,項目名稱:sagsunskoeln-app,代碼行數:7,代碼來源:submission-builder.ts

示例4: setLocation

  setLocation(): void {

    Geolocation.getCurrentPosition().then((position) => {

      this.latitude = position.coords.latitude;
      this.longitude = position.coords.longitude;

      this.maps.changeMarker(position.coords.latitude, position.coords.longitude);

      let data = {
        latitude: this.latitude,
        longitude: this.longitude
      };

      this.dataService.setLocation(data);

      let alert = this.alertCtrl.create({
        title: 'Location set!',
        subTitle: 'You can 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:Arthurisme,項目名稱:Ionic2Expert,代碼行數:27,代碼來源:location.ts

示例5: loadMap

  loadMap(){
    Geolocation.getCurrentPosition().then( (position) => {
	
	  console.log(position.coords.latitude+' '+position.coords.longitude);
      let cur_location = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
      
	  let myStyles=[{
        featureType: "poi",
        elementType: "labels",
        stylers: [{ visibility: "off" }]
      }];
	  
      let mapOptions = {
        center: cur_location,
        zoom: 18,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
		styles: myStyles
      }
 
      this.map = new google.maps.Map(document.getElementById("map"), mapOptions);	  
	  
	  this.marker = new google.maps.Marker({
        map: this.map,
		draggable: true,
        position: cur_location
      });
	  
	  this.map.addListener('click', (event) => {    
        this.moveMarker(event.latLng);    
      });  
	  
    });	
  }
開發者ID:justin1225,項目名稱:diner,代碼行數:33,代碼來源:diner.ts

示例6: getGeo

 getGeo() {
     Geolocation.getCurrentPosition().then(resp=> {
         this.latitude = resp.coords.latitude;
         this.longitude = resp.coords.longitude;
         this.altitude = resp.coords.altitude
     })
 }
開發者ID:ralphowino,項目名稱:ionic-native-kitchen-sink,代碼行數:7,代碼來源:geolocation.ts

示例7: findMe

 findMe(event) {
     Geolocation.getCurrentPosition().then((response) => {
         this.lat = response.coords.latitude;
         this.long = response.coords.longitude;
         this.altitude = response.coords.altitude;
     }, (error) => {
         console.log("Error: ", error);
     });
 }
開發者ID:webdeziner,項目名稱:geolocationApp,代碼行數:9,代碼來源:home.ts

示例8: Promise

 return new Promise((resolve) => {
   Geolocation.getCurrentPosition(this.optionsGeoLoc).then((resp) => {
     //console.log(resp);
     this.currentLoc = resp;
     resolve(this.currentLoc);
   }, error => {
     this.currentLoc = this.defaultLoc;
     resolve(this.currentLoc);
   });
 });
開發者ID:thgautier92,項目名稱:ionicV2,代碼行數:10,代碼來源:gMap.ts

示例9: updateUserLocation

  private updateUserLocation(){
    Geolocation.getCurrentPosition().then((resp) => {
     this.userInfo.setUserInfo(UserInfoService.PREF_USER_LOCATION_LAT, resp.coords.latitude);
     this.userInfo.setUserInfo(UserInfoService.PREF_USER_LOCATION_LON, resp.coords.longitude);

     this.firebase.storeUserLocationFromPrefs();
    }).catch((error) => {
      console.log('Error getting location', error);
    });
  }
開發者ID:smukov,項目名稱:AvI,代碼行數:10,代碼來源:profilePage.ts

示例10: getPosition

 getPosition(){
   console.log("click");
   Geolocation.getCurrentPosition()
   .then(rta =>{
     console.log(rta);
   })
   .catch(error=>{
     console.log(error);
   })
 }
開發者ID:EscuelaIt,項目名稱:class8-ionic-2,代碼行數:10,代碼來源:home.ts


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