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

TypeScript core.MapsAPILoader类代码示例

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

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



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

示例1: constructor

 constructor(
   private mapsAPILoader: MapsAPILoader,
   private searchService: SearchService
 ) {
   this.mapsAPILoader.load().then(() => {
     this.geocoder = new google.maps.Geocoder();
   });
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:8,代码来源:reverse-geocode.service.ts


示例2: ngOnInit

  ngOnInit() {
    // TODO: style icon inside autocomplete? https://developers.google.com/maps/documentation/javascript/places-autocomplete
    this.mapsAPILoader.load().then(() => {
      const autocomplete = new google.maps.places.Autocomplete(this.originInput.nativeElement, {
        types: ['address']
      });
      autocomplete.addListener('place_changed', () => {
        // get the place result
        const place: google.maps.places.PlaceResult = autocomplete.getPlace();

        // verify result
        if (place.geometry === undefined || place.geometry === null) {
          return;
        }

        // set name, latitude, longitude
        const address = this.originInput.nativeElement.value;
        const coords = {
          lat: place.geometry.location.lat(),
          lng: place.geometry.location.lng()
        };
        this.searchService.originNewLocation(address, coords);
        // this.searchService.originChange(address, coords);
        this.searchService.updateInputFocus();
      });
    });
  }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:27,代码来源:origin-input.component.ts


示例3: ngOnInit

  ngOnInit() {
    this.mapsAPILoader.load().then(() => {
      const autocomplete = new google.maps.places.Autocomplete(this.destinationInput.nativeElement, {
        types: ['address']
      });
      autocomplete.addListener('place_changed', () => {
        // get the place result
        const place: google.maps.places.PlaceResult = autocomplete.getPlace();

        // verify result
        if (place.geometry === undefined || place.geometry === null) {
          return;
        }

        // set name, latitude, longitude
        const address = this.destinationInput.nativeElement.value;
        const coords = {
          lat: place.geometry.location.lat(),
          lng: place.geometry.location.lng()
        };
        this.searchService.destinationNewLocation(address, coords);
        this.searchService.updateInputFocus();
      });
    });
  }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:25,代码来源:destination-input.component.ts


示例4: catch

      return Observable.create(observer => {
        try {
            //at this point the variable google may be still undefined (google maps scripts still loading)
            //so load all the scripts, then...
            this.__loader.load().then(() => {
                let geocoder = new google.maps.Geocoder();
                geocoder.geocode({ address }, (results, status) => {

                    if (status === google.maps.GeocoderStatus.OK) {
                        const place = results[0].geometry.location;
                        observer.next(place);
                        observer.complete();
                    } else {
                        console.error('Error - ', results, ' & Status - ', status);
                        if (status === google.maps.GeocoderStatus.ZERO_RESULTS) {
                            observer.error('Address not found!');
                        }else {
                            observer.error(status);
                        }
                        
                        observer.complete();
                    }
                });
            });
        } catch (error) {
            observer.error('error getGeocoding' + error);
            observer.complete();
        }

    });
开发者ID:intermadix,项目名称:XBMS-webapp,代码行数:30,代码来源:googlemap.service.ts


示例5: ngAfterViewInit

  ngAfterViewInit() {
    this.mapsAPILoader.load().then(() => {

      this.apiWrapper.getNativeMap().then((m) => {
        this.mapService.initializeMapFromMapExtension(m);

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

    this.geolocationService.getCurrentPosition();
  }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:13,代码来源:map-extension.directive.ts


示例6: ngOnInit

  ngOnInit() {
        //change the title back to normal 
        document.getElementById('title').innerHTML = 'Google Bytes';

    // functionality to allow for autocomplete
    this.mapsAPILoader.load().then( () => {
      let autocomplete = new google.maps.places.Autocomplete(this.searchElement.nativeElement, {
        types:[]});
      autocomplete.addListener('place_changed', ()=>{
        this.ngZone.run(()=>{
          let place: google.maps.places.PlaceResult = autocomplete.getPlace();
          //takes the lat and long from the auto complete and inserts them into the globals
          this.lat = place.geometry.location.lat();
          this.long = place.geometry.location.lng();
        })
      })
    });
  }
开发者ID:adb88bernal,项目名称:googleBytes,代码行数:18,代码来源:search.component.ts


示例7: ngOnInit

  ngOnInit() {
    this.searchElementRef.nativeElement.value = this.address || '';

    this.mapsAPILoader.load().then(() => {
      let autocomplete = new google.maps.places.Autocomplete(
        this.searchElementRef.nativeElement,
        {
          types: ['address']
        }
      );
      autocomplete.addListener('place_changed', () => {
        this.ngZone.run(() => {
          //get the place result
          let place: google.maps.places.PlaceResult = autocomplete.getPlace();
          //verify result
          if (place.geometry === undefined || place.geometry === null) {
            return;
          }
          // this.address.search = this.searchElementRef.nativeElement.value;
          // place.address_components.forEach((address_component, index) => {
          //   console.log(address_component);
          //   if (address_component.types.includes('locality'))
          //     // this.addressForm.setValue({ city: address_component.long_name });
          //     this.address.city = address_component.long_name;
          //   else if (
          //     address_component.types.includes('administrative_area_level_1')
          //   )
          //     // this.addressForm.setValue({ state: address_component.long_name });
          //     this.address.state = address_component.long_name;
          //   else if (address_component.types.includes('country'))
          //     // this.addressForm.setValue({
          //     //   country: address_component.long_name
          //     // });
          //     this.address.country = address_component.long_name;
          // });
          this.addressChanged.emit(place);
        });
      });
    });
  }
开发者ID:danish-jamil,项目名称:Place-autocomplete-component,代码行数:40,代码来源:places-autocomplete.component.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript utils.str_enum函数代码示例发布时间:2022-05-28
下一篇:
TypeScript geom.Point类代码示例发布时间: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