Close InfoWindow by Clicking on Map

New home Forums Pro Add-on General queries Close InfoWindow by Clicking on Map

Tagged: 

This topic contains 6 replies, has 3 voices, and was last updated by  bigfootjohn 1 week, 1 day ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #53604

    Is it possible to have InfoWindows close when you click anywhere outside of the infoWindow, instead of only closing when you click the X?

    #53610

    Steven
    Moderator

    Hi there,

    Thank you so much for getting in touch, we really appreciate your time.

    This is possible using the custom JavaScript field built into WP Google Maps.

    Please navigate to -> Maps -> Settings -> Advanced -> Please paste the below script into the custom JavaScript field,

    jQuery(window).load(function() {
    if(typeof MYMAP !== ‘undefined’){
    for(var mapindex in MYMAP){
    google.maps.event.addListener(MYMAP[mapindex].map.googleMap, ‘click’, function(e) {

    // close infowindows
    infoWindow.forEach(function(entry, index) {
    infoWindow[index].close();
    });
    });
    }
    }

    });

    Please then click save and confirm if this helps?

    I look forward to hearing back from you.

    Kindest Regards,
    Steven De Beer

    #53674

    bigfootjohn
    Member

    Hi,

    This didnt work for me.

    #53676

    Steven
    Moderator

    Hi there,

    Thank you so much for getting back to us.

    Could I kindly ask you to provide us with a link to your website so that we may take a closer look at some custom script specific to your site?

    I look forward to hearing back from you.

    Kindest Regards,
    Steven De Beer

    #53963

    bigfootjohn
    Member

    Seems that is issues with this forum. Sometimes it is removing some lines/snippets from code.

    Can you please check the code again and attach it in a text file instead?

    #53966

    Steven
    Moderator

    Hi again,

    Thank you so much for getting back to us.

    Could I kindly ask what versions of WP Google Maps you are currently using?

    This custom script which I have attached should function correctly on V7 of WP Google Maps, however, should probably not function on older versions of WP Google Maps.

    I look forward to hearing back from you.

    Kindest Regards,
    Steve

    Attachments:
    You must be logged in to view attached files.
    #53972

    bigfootjohn
    Member

    Worked like a charm. Thank you!

    #53973

    Steven
    Moderator

    Hi again,

    Thank you so much for getting back to me.

    I am glad to hear this worked correctly for you. 🙂

    Please do let us know if there is anything more we can help with as we are always eager to assist.

    Do have a pleasant day further.

    Kindest Regards,
    Steven De Beer

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.