Подключение скрипта карт
RoundArh opened this issue · 1 comments
RoundArh commented
Каждая инициализация карты добавляет строку
<script type="text/javascript" defer="" id="YaScript" src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&callback=angular2YAMapsAPILoader"></script>kodermax commented
public createMap(el: HTMLElement, mapOptions: mapTypes.MapOptions): Promise<void> {
const create = () => setTimeout(() => {
if (ymaps.Map) {
if (mapOptions.searchControl) {
const inputSearch = new ymaps.control.SearchControl(mapOptions.searchControl)
mapOptions.controls.push(inputSearch)
}
const map = new ymaps.Map(el, mapOptions)
this._mapResolver(map as mapTypes.YandexMap)
} else {
create()
}
}, 100)
if (this.checkYaSciptLoaded() === null) {
const res = this._loader.load().then(() => {
create()
}).catch((e) => console.log(e))
return res
} else {
create()
}
}