Title: Interact with the maps objects script not working
Last modified: October 18, 2022

---

# Interact with the maps objects script not working

 *  [Kyle Haney](https://wordpress.org/support/users/globetrotterkyle/)
 * (@globetrotterkyle)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/)
 * Hello,
 * I’ve had Traveler’s map for over a year now with no issues. On one of my website’s
   pages ([https://globetrotterkyle.com/korea-adventures/](https://globetrotterkyle.com/korea-adventures/)),
   I have the shortcode [travlers-map] added and the following script added so that
   the map only shows South Korea.
 * <script>
    // Listen for the event. document.addEventListener(‘cttm_map_loaded’,
   function (e) { // cttm_map is an array of all the maps included in the page, 
   so we loop through each. for (let i = 0; i < cttm_map.length; i++) { //You can
   now interact with the map object. cttm_map[i].setView([45.30824,5.85554], 10);}},
   false); </script>
 * The map loads perfectly and it looks exactly the way I want it to.
 * Now I am trying to add a separate, new page to my website where I only want to
   show Europe. However, I’m using the same shortcode and script and I’m getting
   an error. When I remove the script, I’m only able to show a map of the entire
   world.
 * What am I doing wrong? I want to have the traveler’s map show only europe but,
   it’s showing the entire world. Please help!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Finteract-with-the-maps-objects-script-not-working%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Camille V](https://wordpress.org/support/users/socrapop/)
 * (@socrapop)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/#post-16119317)
 * Dear Kyle,
 * Could you please add the error message you have in the console here, so I can
   help you?
    Or maybe send me the link to the page with the error?
 * If the script is working on one page, there is no reason it would not work on
   another page.
 * Let me know,
    Camille
 *  Thread Starter [Kyle Haney](https://wordpress.org/support/users/globetrotterkyle/)
 * (@globetrotterkyle)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/#post-16276803)
 * Hello,
 * The error I’m getting is, “Updating failed. The response is not a valid JSON 
   response.”
 * Side note, I tried to update the script on my page where it is actually working(
   [https://globetrotterkyle.com/korea-adventures/](https://globetrotterkyle.com/korea-adventures/))
   and now I’m getting the same error.
 * So, I can’t load the scipt into new pages, and on pages where the script does
   work, I can’t update those pages. I get the error, “Updating failed. The response
   is not a valid JSON response” each time.
 * I have the latest version of WordPress and Travler’s Map downloaded, so I’m not
   sure what the problem is.
 *  Thread Starter [Kyle Haney](https://wordpress.org/support/users/globetrotterkyle/)
 * (@globetrotterkyle)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/#post-16276843)
 * Ok, very strange but, I figured out a way around it. I had to use the Classical
   Editor in WordPress to get around the JSON issue.
 * Once I deactivated Gutenberg in the plug-in menu, and added the script using 
   the Classic Editor plug-in, it worked just fine. Then, when I reverted back to
   Gutenberg, I got the JSON error again.
 * So, in summary, I cannot use the Traveler’s Map script while using Gutenberg 
   block editor on pages or posts. When I use Classical Editor to edit posts/pages,
   I’m able to use the Traveler’s Map script to center the map where I want.
 * I hope this helps you in fixing this bug!
 * P.S. for anyone else who has this exact problem, go to your plug-in menu on your
   wordpress homepage and download the Classic Editor first. Then, copy the script
   that the developer put on his homepage so that you can center your map where 
   you wish. Then, deactivate the Gutenberg plug-in within WordPress, and activate
   classic editor. I used this website ([https://www.wpbeginner.com/wp-tutorials/how-to-edit-html-in-wordpress-code-editor-beginners-guide/](https://www.wpbeginner.com/wp-tutorials/how-to-edit-html-in-wordpress-code-editor-beginners-guide/))
   to help me add the developer’s script into my website’s page using the developer’s
   script. I hit update/save and it worked just fine. Good luck!
 *  Plugin Author [Camille V](https://wordpress.org/support/users/socrapop/)
 * (@socrapop)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/#post-16276897)
 * Oh I see, you were adding the script code inside your editor!
 * Usually developers do this in the website’s files directly, so I did not understand
   🙂
    The error you have comes from Gutenberg yes, I already had this error when
   a plugin or something in the code was triggering an error.
 * Do you have any other plugins that add blocks or change the edit area in any 
   way? Or maybe a security plugin that doesn’t accept adding javascript into your
   content?
 * In Gutenberg editor, were you adding the script inside a “Custom HTML” block?
 * I can’t reproduce your issue on my end, maybe it’s another plugin misbehaving
   with Travelers’ map. Or the things I said just before.
 * Just to be clear, when you don’t have the script but only Travelers’ Map, everything
   is working?
 *  Thread Starter [Kyle Haney](https://wordpress.org/support/users/globetrotterkyle/)
 * (@globetrotterkyle)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/#post-16277138)
 * I was adding the code in the Gutenberg “Custom HTML” block, yes.
 * The only plug-in I’ve downloaded since installing Traveler’s Map is Fotomoto.
   Perhaps that’s the issue but, I can’t be sure. It’s weird that it used to work
   months ago but now seems to give me an error…
 * Everything else is working just fine, yes 🙂 thanks for creating this!

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

The topic ‘Interact with the maps objects script not working’ is closed to new replies.

 * ![](https://ps.w.org/travelers-map/assets/icon-256x256.jpg?rev=2100131)
 * [Travelers' Map](https://wordpress.org/plugins/travelers-map/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/travelers-map/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/travelers-map/)
 * [Active Topics](https://wordpress.org/support/plugin/travelers-map/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/travelers-map/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/travelers-map/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Kyle Haney](https://wordpress.org/support/users/globetrotterkyle/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/interact-with-the-maps-objects-script-not-working/#post-16277138)
 * Status: not resolved