当前位置: 首页>>代码示例>>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;未经允许,请勿转载。