Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
For everyone who came here from a search, I advise you to use
https://github.com/effrenus/yandex-map-react
Who needs it, I did this:
thanks for the code https://bradb.net/blog/promise-based-js-script-loader/
function script(url) {
if (Array.isArray(url)) {
let self = this;
let prom = [];
url.forEach(function (item) {
prom.push(self.script(item));
});
return Promise.all(prom);
}
return new Promise(function (resolve, reject) {
let r = false;
let t = document.getElementsByTagName('script')[0];
let s = document.createElement('script');
s.type = 'text/javascript';
s.src = url;
s.async = true;
s.onload = s.onreadystatechange = function () {
if (!r && (!this.readyState || this.readyState === 'complete')) {
r = true;
resolve(this);
}
};
s.onerror = s.onabort = reject;
t.parentNode.insertBefore(s, t);
});
}
script('//api-maps.yandex.ru/2.1/?lang=ru_RU').then(() => {
const ymaps = global.ymaps;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question