AnteaterKit / angular2-yandex-maps

Angular 2 components Yandex Maps.
27 stars 23 forks source link

Подключение скрипта карт #25

Open RoundArh opened 6 years ago

RoundArh commented 6 years ago

Каждая инициализация карты добавляет строку

kodermax commented 6 years ago
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()
    }
  }