Я хочу извлечь изображения Google google из идентификатора места в моем приложении angular2. Я получаю место от метода Autocomplete.Angular2: Как получить фотографии google place из идентификатора места?
Я использую angular2-google-map library.
import { Component, NgZone, Inject, OnInit, ViewChild, EventEmitter, ElementRef } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AgmCoreModule, MapsAPILoader } from 'angular2-google-maps/core';
declare var google: any;
@Component({
selector: 'add-location-component',
templateUrl: './addLocation.component.html'
})
export class AddLocationComponent implements OnInit {
private googlePlaceId: any;
@ViewChild("search")
public searchElementRef: ElementRef;
public searchControl: FormControl;
constructor(
public authService: AuthService,
private mapsAPILoader: MapsAPILoader,
@Inject(NgZone) private ngZone: NgZone
) { }
ngOnInit() {
this.searchControl = new FormControl();
this.mapsAPILoader.load().then(() => {
let autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, {
types: ["address"]
});
autocomplete.addListener("place_changed",() => {
this.ngZone.run(() => {
let place = autocomplete.getPlace();
if (place.geometry === undefined || place.geometry === null) {
return;
}
this.googlePlaceId = place.place_id;
console.log(this.googlePlaceId);
});
});
});
}
}
Используя place_id или Lattitude и долготы я хочу принести первые 10 фотографий этого места. Я застрял здесь с угловой2-google-картой.
Можете ли вы, ребята, помочь мне. Спасибо.
Я пытался в соответствии с вашим решением, но получаю эту ошибку ** google.maps.PlacesService не конструктор ** –
вы, вероятно, не имеют место библиотеки загружены – ValLeNain
Да, я добавил 'AgmCoreModule.forRoot ({ apiKey: GOOGLEAPIKEY, библиотека: [ "место"] }) ' –