Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getYandexMapScript() {
  2.                         return new Promise(function(resolve, reject){
  3.                             if (window.ymapsReady && !window.ymapsLoading) { return resolve(); }
  4.  
  5.                             if (!window.ymapsReady) {
  6.                                 var ymapsChecker = setInterval(function(){
  7.                                     if (window.ymapsReady) {
  8.                                         console.log(window.ymapsReady);
  9.                                         clearInterval(ymapsChecker);
  10.                                         return resolve();
  11.                                     }
  12.                                 }, 200);
  13.                             }
  14.  
  15.                             window.ymapsLoading = true;
  16.                             $.cachedScript('https://api-maps.yandex.ru/2.1/?lang=ru_RU')
  17.                                 .done(function () {
  18.                                     ymaps.ready(function(){
  19.                                         window.ymapsReady = true;
  20.                                     });
  21.                                 })
  22.                                 .fail(function(){
  23.                                     return reject();
  24.                                 });
  25.                         });
  26.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement