Forum Replies Created

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

    (@jacques-l)

    Dear Camille,

    Sorry to come back to this thread, but I would like to disable popup link after click on a marker (I just would like to see post title and excerpt).

    I tried this, but click always redirects to post

    $('.tooltip-link').on('click', function(e){
          e.preventDefault();
        });
    

    Am I missing something ?

    Thanks a lot

    Thread Starter Jacques L

    (@jacques-l)

    Like the map object, do you think I should set the marker objects array publicly on the front-end so developers can interact with them

    It’s a very a good idea 🙂 but don’t use my solution, as it is far from ideal.

    Let’s have a closer look.
    For example when I put a console log here :

    cttm_map[0].eachLayer(function(layer){
       layer.addEventListener(‘click’, function(element) {
    
          var layerLat = element.latlng.lat;
          var layerLng = element.latlng.lng;
          console.log('hey')
    
        ...stuff here to target matching elements and do some actions...
       })
    });

    It returns “hey” 4 times! It looks like ‘layer’ is made of 4 objects, so actions in this code are executed 4 times. Maybe it’s something else I didn’t understand.
    In my use case it’s not a problem because it triggers a slow animation, so the 4 times triggers is so fast that it’s not visible.
    But it’s definitely not optimal, so if you find another solution that can be added to the plugin it may be useful for others (and me for sure :D)?

    Anyway, your plugin already help so much, way more than others fancy-but-buggy ones 🙂

    Thread Starter Jacques L

    (@jacques-l)

    sorry for failing with the code tag, it looks dirty 😀

    Thread Starter Jacques L

    (@jacques-l)

    Dear Camille,

    Thanks a lot for your answer.

    I found and tried this solution before, without success.
    After posting my message I tried to change a bit this code, and it finally works.
    Here how it looks

    cttm_map[0].eachLayer(function(layer){
    

    layer.addEventListener(‘click’, function(element) {

       var layerLat = element.latlng.lat;
    

    var layerLng = element.latlng.lng;

     ...stuff here to target matching elements and do some actions...
    

    })
    `});

    I couldn’t make work the “if(layer instanceof L.Marker)” part of the example you gave me, but it’s ok with the code I just wrote.
    The annoying thing is it works almost everywhere, except in some random Safari versions. I’ll explore further to understand why.
    Maybe because a “console.log(element.latlng)” returns 3 times the coordonates.
    Anyway, it works on other browsers, so it’s ok for me now.

    About yout first question

    Did you modify anything in the plugin to achieve what you have now or is it only a zoom on the map at the desired location?

    I didn’t touch at all the plugin, as I always avoid this solution, for the reason you explained.

    Sorry for my english, it’s a bit hard to explain exactly what I achieved and wanted to achieve 🙂

    If you’re interested, I’ll post here a link of the page with map when the website will be released!

    Once again, thanks a lot.

    Have a nice evening 🙂

    Jacques

    Hi Ahmed,

    ME and my friend are both using Xenu

    Thanks for your answer!

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