Hi @svenatkins,
Actually yes. The map object is called oumMap in Javascript. Here you’ll find the LeafletJS documentation on what you can do with it: https://leafletjs.com/reference.html
Best regards,
Daniel
Hi Daniel,
unfortunately that didn’t work for me.
I have added a script to a page below the map, the map is added via WordPress, the script in the template file.
document.querySelectorAll('.btn_swiper').forEach(link=> {
link.addEventListener('click', function() {
const lng = document.querySelector('.swiper-slide-active').getAttribute('data-longitude');
const lat = document.querySelector('.swiper-slide-active').getAttribute('data-latitude');
console.log(lng, lat);
oumMap.flyTo([lat,lng], 18);
})
})
And I get the following error: oumMap.flyTo([lat,lng], 18);
When I add the script in the file: frontend-block-map.js with map.flyto… it works fine.
But I need it in combination with the swiper.js
Thanks,
Sven
Hey @svenatkins,
Did you try to wrap your code inside
$('document').ready(function(){
// your code
});
?
If you like to avoid jquery you’d need to use a vanilla JS equivalent.
Best Regards,
Daniel
-
This reply was modified 3 years, 10 months ago by
100plugins.
Hi Daniel,
sorry no luck with jQuery.
Uncaught ReferenceError: oumMap is not defined
Do I have to activate a setting somewhere to make it work?
Thanks,
Sven
I found the error: was testing with version 1.2.19. It works fine with version 1.2.20.
Sorry.
Ah! Yeah, I should have told you that I added this feature with version 1.2.20
Best regards,
Daniel