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 4 posts - 1 through 4 (of 4 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

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