Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RoundArh opened this issue Apr 18, 2018 · 1 comment
Open

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

RoundArh opened this issue Apr 18, 2018 · 1 comment

Comments

@RoundArh
Copy link

RoundArh commented Apr 18, 2018

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

<script type="text/javascript" defer="" id="YaScript" src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&callback=angular2YAMapsAPILoader"></script>
@kodermax
Copy link

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()
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants