Title: Access the map object with another script
Last modified: July 17, 2022

---

# Access the map object with another script

 *  Resolved [svenatkins](https://wordpress.org/support/users/svenatkins/)
 * (@svenatkins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/)
 * Hello,
    it is possible to access the map object with another script after the
   map is initialized?
 * Greetings,
    Sven

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [100plugins](https://wordpress.org/support/users/100plugins/)
 * (@100plugins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15835067)
 * Hi [@svenatkins](https://wordpress.org/support/users/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](https://leafletjs.com/reference.html)
 * Best regards,
    Daniel
 *  Thread Starter [svenatkins](https://wordpress.org/support/users/svenatkins/)
 * (@svenatkins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15835596)
 * 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
 *  Plugin Author [100plugins](https://wordpress.org/support/users/100plugins/)
 * (@100plugins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15845230)
 * Hey [@svenatkins](https://wordpress.org/support/users/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](https://wordpress.org/support/users/100plugins/).
 *  Thread Starter [svenatkins](https://wordpress.org/support/users/svenatkins/)
 * (@svenatkins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15845614)
 * 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
 *  Thread Starter [svenatkins](https://wordpress.org/support/users/svenatkins/)
 * (@svenatkins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15845836)
 * I found the error: was testing with version 1.2.19. It works fine with version
   1.2.20.
 * Sorry.
 *  Plugin Author [100plugins](https://wordpress.org/support/users/100plugins/)
 * (@100plugins)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15857857)
 * Ah! Yeah, I should have told you that I added this feature with version 1.2.20
 * Best regards,
    Daniel

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Access the map object with another script’ is closed to new replies.

 * ![](https://ps.w.org/open-user-map/assets/icon-256x256.png?rev=2779645)
 * [Open User Map](https://wordpress.org/plugins/open-user-map/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/open-user-map/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/open-user-map/)
 * [Active Topics](https://wordpress.org/support/plugin/open-user-map/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/open-user-map/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/open-user-map/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [100plugins](https://wordpress.org/support/users/100plugins/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/access-the-map-object-with-another-script/#post-15857857)
 * Status: resolved