Привет, я боролся с импортом библиотеки JS Google Maps.Я установил библиотеку @ google / maps с помощью npm, но не могу импортировать ссылку на эту библиотеку в файле компонента.
Я попробовал все, что упомянуто в этом вопросе: @types/googlemaps/index.d.ts 'не является модулем
, но все же я не могуиспользуйте карты Google в моем компоненте.
Вот что я делаю в своем коде:
/// <reference types="@types/googlemaps" />
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import {} from '@google/maps';
@Component({
selector: 'app-main-search',
templateUrl: './main-search.component.html',
styleUrls: ['./main-search.component.scss']
})
export class MainSearchComponent implements OnInit {
@ViewChild('city', { read: ElementRef }) searchCityInput:ElementRef;
listOfOption = ['Java Developer', 'Java Team Lead', 'Java Architect', 'Java Programmer', 'Senior Java Developer'];
listOfSelectedValue = [ ];
recent_active = false;
constructor(private router: Router) { }
ngOnInit(): void {
const autocomplete = new google.maps.places.Autocomplete(this.searchCityInput.nativeElement);
console.log("Input: ", autocomplete);
//Event listener to monitor place changes in the input
google.maps.event.addListener(autocomplete, 'place_changed', () => {
//Emit the new address object for the updated place
// this.onSelect.emit(this.getFormattedAddress(autocomplete.getPlace()));
console.log("Formated Address: ", autocomplete.getPlace());
});
}
onSubmit() {
this.router.navigateByUrl('/search/results');
}
}
Я получаю эту ошибку:
ОШИБКА TypeError: Не удается прочитать свойство 'Автозаполнение' из неопределенного