How to change default behavior of marker from “show” to “hide”

New home Forums Pro Add-on General queries How to change default behavior of marker from “show” to “hide”

Tagged: ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #67465
    neoteric
    Participant

    hello, is it possible to change the default behavior of the markers in a map from “show” to “hide”?

    This is what i am trying to accomplish –

    1) When the map is loaded, the marker should be hidden by default
    2) A user can use the filter to make markers in the area show up
    2) When all filters are selected, all markers is shown. Similarly, when all filters are not selected, all markers are hidden.

    Is it possible with custom JS codes?

    #67479
    Matthew
    Moderator

    Hi there,

    Thank you for getting in touch with us, we do appreciate your time.

    Yes, this possible with the use of some custom JS code which can be entered in the “Custom JS” setting block (Maps -> Settings -> Advanced).

    Please see the custom JS code used to achieve this below:

    jQuery(function($){
    var wpgmzaCanHide = true;
    jQuery(document.body).on(“markersplaced.wpgmza”, function(){
    wpgmzaHideAllMarkers();
    });
    function wpgmzaHideAllMarkers(){
    if(wpgmzaCanHide){
    for(var mI in WPGMZA.maps[0].markers){
    WPGMZA.maps[0].markers[mI].setVisible(false);
    }
    wpgmzaCanHide = false;
    }
    }
    });

    I hope this helps and answers your question?

    Should you have any further questions, I am more than happy to help.

    Kindest Regards,
    Matthew

    #67517
    neoteric
    Participant

    matthew,

    thanks for the reply! the code works for point (1) in my post. The markers are hidden on page load.

    However, when all filters are not selected, all the markers are still showing.

    kindly advise. thanks!!

    #67544
    Matthew
    Moderator

    Hi there,

    Thank you for getting back to me and for your time on this.

    Please could I kindly ask if you may send me the link to your map on your site as this will allow me to take a closer look and potentially write the respective code for this?

    Please may you send it to “[email protected]” should you wish to keep your site private from the public?

    I look forward to your response.

    Kindest Regards,
    Matthew

    #80601
    [email protected]
    Participant

    Hello,
    I know this post it’s from a long time, but I have the same problem. The script works when load the page but, like #neoteric, when all filters are not selected, all marlers showing.

    Do you remember how was the solution?

    #80607
    Matthew
    Moderator

    Hi @statplans,

    Thank you for getting in touch with us, we do appreciate your time.

    This may now be possible using a built-in setting called “Hide all markers until search is done” and thus no custom JS code is needed.

    Please see the below navigation paths to find this setting depending on which UI build you are currently using:
    – Atlas Novus: Maps -> Edit -> Settings -> Store Locator -> Advanced
    – Legacy: Maps -> Edit -> Store Locator.

    Please let me know if this helps?

    I look forward to hearing back from you.

    Kindest Regards,
    Matthew

    #80613
    [email protected]
    Participant

    Thanks for your answer,

    thats works when map load, none marker is showing. But I have the category filtering (check boxes) and when I check one category appears the markers for than category, but when I uncheck again apperars all markers. I need to hide all markers when none category are checked

    #80631
    Matthew
    Moderator

    Hi @statplans,

    Thank you for getting back to me and for your time on this.

    Thank you for the confirmation, please may I ask if you may provide me with the link to your map so that I may take a closer look and run a few tests?

    I look forward to hearing back from you.

    Kindest Regards,
    Matthew

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.