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


TypeScript core.MapsAPILoader類代碼示例

本文整理匯總了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;未經允許,請勿轉載。