Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter nikosillo

    (@nikosillo)

    It works perfectly with the previous version, 1.12.1.
    I attach another page with this version where it works correctly.
    The button is from The Plus Elementor, which allows me to insert a shortcode for asign a class and data.postid. The function calls a popup leaflet map.

    // Listen for the event triggered when Travelers' Map is loaded
    document.addEventListener('cttm_map_loaded', function (e) {
    
        //Find all the buttons and add a click event on each
        document.querySelectorAll('.button-link-wrap').forEach((a) => {
          //Get the post id "data-" attribute on the button
          const postID = a.dataset.postid;
          a.addEventListener('click', function (event) {
    		//console.log('link assigned?');
            findAndOpenMarker(postID);
          });
    
          function findAndOpenMarker(postID) {
            // We only have one map, so we will use cttm_markers[0]. If you want to work with multiple maps, you will have to add a second loop.
            for (let i = 0; i < cttm_markers[0].length; i++) {
              // If the marker post ID is the same as the button we clicked AND if it's the main marker.
              if (
                cttm_markers[0][i].additionalData.postid == postID &&
    			cttm_markers[0][i].additionalData.multipleMarkersIndex == 0
              ) {
                
                // If the icon is not on the map, it means it's inside a cluster, 
                // so you have to use .spiderfy() on the parent cluster to open the popup.
                // This will save you a lot of time understanding why it's not working ^^'
                if (!cttm_markers[0][i]._icon) {
                  cttm_markers[0][i].__parent.spiderfy();
                }
                // Open the marker popup
    				//console.log('is modal open or not?');
    			cttm_markers[0][i].openPopup();
    				// Add a nice transition
    			cttm_map[0].panTo(cttm_markers[0][i].getLatLng(), {
                   animate: true,
                   duration: 1,
                });
    	            		
    			
              }
            }
          }
        });
      }, false);

    The “Visit” button “Map” works in the same way, outside the popup.

    This other page shows it working fine with the previous version.

    https://alpujarras-qr.legadoandalusi.es/lanjaron/


    Maybe it’s silly, my knowledge is limited, but it worked. There’s probably something I need to change…
    Thanks

    Thread Starter nikosillo

    (@nikosillo)

    Thanks for the help. I have not found a way to add the instruction and make it work, but it does not matter, with the developer options that it facilitates I have been able to build another more visually attractive map option for my site, so thank you very much

    Thread Starter nikosillo

    (@nikosillo)

    Camille…. Maybe I can abuse your generosity a little more and ask your opinion about another problem that happens on the same website.
    Every time one of the Points of Interest is opened in a modal window, the map appears locating said point. The information is extracted from a post using the All AE Templates plugin. The map is not displayed unless the browser window is resized, and then it is displayed correctly. Any suggestions how I could fix this problem?

    Thread Starter nikosillo

    (@nikosillo)

    Oh boy, thank you very, very much!!! it works perfectly!!! I feel like a fool, I really appreciate it

    yo acabo de actualizarlo y me sucede exactamente lo mismo. A la espera de alguna solución, habrá que volver a la versión anterior, es un gran plugin 🙁

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