Skip to content

Instantly share code, notes, and snippets.

@webag
Created October 14, 2019 06:53
Show Gist options
  • Save webag/cd354113344e058398cce167bfb54927 to your computer and use it in GitHub Desktop.
Save webag/cd354113344e058398cce167bfb54927 to your computer and use it in GitHub Desktop.
Загрузка карты по waypoint. Map waypoint load
function initMap(){
let myMap = new ymaps.Map("map", {
center: [55.76, 37.64],
zoom: 7
});
}
$(function($){
function addScript(src) {
let s = document.createElement('script');
s.setAttribute('src', src);
document.body.appendChild(s);
}
const geoSection = $('.s-map');
if (geoSection.length){
geoSection.waypoint(function () {
addScript('https://api-maps.yandex.ru/2.1/?apikey=fc8e2c55-0d43-4696-a7a9-853c1b80e268&lang=ru_RU&onload=initMap');
this.destroy();
}, {
offset: '100%'
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment