• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript geolocation.Geolocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ionic-native/geolocation.Geolocation的典型用法代码示例。如果您正苦于以下问题:TypeScript Geolocation类的具体用法?TypeScript Geolocation怎么用?TypeScript Geolocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Geolocation类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

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


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


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


示例4:

   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


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


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


示例7: mapSetUp

    /*
        here is where the map object is initialized
        it is centered and zoomed in to an appropriate level and
        contained in the appropriate bounds
        and populated with all the markers
    */
    mapSetUp() {

      //here is where the phone's geolocation is first defined
      //there is also an error function just incase the setup was unsuccessful
      //var userLoc = undefined;
      this.geolocation.getCurrentPosition({timeout: 10000, enableHighAccuracy: true}).then((position) => {
    
          this.userLoc = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
          
      }).catch((error) =>{

                console.log('problem getting location', error);
                alert('code: ' + error.code +'\n'
                   + 'message: ' + error.message + '\n');
                this.userLoc = undefined;
      });

      //here is where the map is initialized, if the user's geolocation is defined and within mapBounds, 
      //then it is the map's center, otherwise the default center is used
      let options = {
         center: (this.userLoc !== undefined && this.mapBounds.contains(this.userLoc)) ? this.userLoc : this.areaCenter,
         zoom: 17,
         mapTypeId: google.maps.MapTypeId.ROADMAP
      }

      this.map = new google.maps.Map(document.getElementById("map"), options);

      //here is where we set up a "position watcher" that should listen to a change in the user's location and update the user's
      //marker accordingly
      this.locWatcher = this.geolocation.watchPosition()
                        .filter((p) => p.coords !== undefined)  
                        .subscribe(position => {
                            let newUserLoc = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                            this.updateUserMark(newUserLoc);
                        });

    
    }
开发者ID:cs480-capstone,项目名称:Tree-TreeFactory,代码行数:44,代码来源:integratedmap.ts


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


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


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



注:本文中的@ionic-native/geolocation.Geolocation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript google-plus.GooglePlus类代码示例发布时间:2022-05-28
下一篇:
TypeScript firebase.Firebase类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap