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


TypeScript ionic-native.Geolocation類代碼示例

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


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

示例1: startTracking

  startTracking() {
    console.log(":startTracking: ", BackgroundGeolocation);
    let options = {
      frequency: 3000,
      enableHighAccuracy: true
    };

    this.watch = Geolocation.watchPosition(options);

    this.watch.subscribe((data) => {
      alert("latitude: "+data.coords.latitude);
      alert("longitude: "+data.coords.longitude);
      console.log("latitude: "+data.coords.latitude);
      console.log("longitude: "+data.coords.longitude);
      this.notifyLocation(data.coords);
    });

    let backgroundOptions = {
      desiredAccuracy: 10,
      stationaryRadius: 10,
      distanceFilter: 30
    };

    this.backGeolocation.configure((location) => {
      this.notifyLocation(location);
    }, (err) => {
      console.log(err);
    }, backgroundOptions);

    this.backGeolocation.start();

    return this.position;
  }
開發者ID:lucascardoso,項目名稱:app-test-plugins-ionic2,代碼行數:33,代碼來源:location-tracker.ts

示例2: 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

示例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: constructor

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

示例5: 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

示例6: 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

示例7: 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

示例8: startWatch

 startWatch() {
   this.subscription = Geolocation.watchPosition(this.options).subscribe(position => {
     this.record=true;
     console.log(position);
     this.geo = position;
   });
 }
開發者ID:thgautier92,項目名稱:ionicV2,代碼行數:7,代碼來源:geolocation.ts

示例9: 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

示例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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。