Category no longer displaying in Infowindow

New home Forums Pro Add-on General queries Category no longer displaying in Infowindow

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #53864
    hepqldadmin
    Member

    Hi

    About a month ago I looked into how to display categories in the Infowindow. I found the following thread https://www.wpgmaps.com/forums/topic/category-in-infowindow-2/ which helped me to do with some custom JS. It was working perfectly. I’ve just noticed today that the category is no longer being displayed in the Infowindow. Can you please assist?

    I’ve attached the custom JS I have used. The weblink is https://www.hepqld.asn.au/hep-nav/

    Thanks Jessie

    Attachments:
    You must be logged in to view attached files.
    #53885
    Perry
    Moderator

    Hi Jessie

    Thank you for getting in touch, sorry to hear you are experiencing issues.

    You have “jQuery” in uppercase (JQUERY) in the code on your site, if you use the correct case – jQuery – then that will start working again.

    Does that help?

    Kind regards
    – Perry

    #53955
    bigfootjohn
    Member

    I’m using this and it seems not to working. Can you please check if something is wrong in the code?

    $=jQuery;
    $(document.body).on(‘infowindowopen.wpgmza’, function(event) {
    var marker = event.target.mapObject;
    var categoryNames = [];
    for (var i = 0; i < marker.categories.length; i++) {
    var category = WPGMZA.categories.getCategoryByID(marker.categories[i]);
    console.log(category);
    if (category) {
    categoryNames.push(category.name);
    }
    }
    var joinedCategoryNames = categoryNames.join(“, “);
    $(‘body’).find(‘.wpgmza_infowindow_title’).after(joinedCategoryNames);
    });

    #53957
    Perry
    Moderator

    Hi John

    Thank you for getting in touch, sorry to hear this isn’t working for you.

    Can you please link us to the site you are experiencing issues with this snippet on?

    Kind regards
    – Perry

    #53962
    bigfootjohn
    Member

    It worked with this one https://pastebin.com/NK2pz5Cd

    #53964
    Perry
    Moderator

    Hi John

    We would need to see the site on which it is not working in order to diagnose why that is.

    Would you be able to provide the URL to the page where this isn’t working?

    Kind regards
    – Perry

    #53994
    hepqldadmin
    Member

    Thanks so much for your help Perry. This has fixed the issue.

    #53995
    hepqldadmin
    Member

    Hi Perry

    Are you able to help with another thing in the InfoWindow please? I’d like to add a space between the category name and the address in the InfoWindow please. How do I do this?

    Thanks

    Jessie

    #54001
    Perry
    Moderator

    Hi Jessie

    Please adjust that to

    $ = jQuery;
    $(document.body).on('infowindowopen.wpgmza', function (event) {
    	
    	var marker = event.target.mapObject;
    	var categoryNames = [];
    	
    	for (var i = 0; i < marker.categories.length; i++) {
    		var category = WPGMZA.categories.getCategoryByID(marker.categories[i]);
    		
    		if (category)
    			categoryNames.push(category.name);
    	}
    	
    	var joinedCategoryNames = categoryNames.join(", ");
    	
    	var p = $("<p class='wpgmza-infowindow-categories'></p>");
    	p.text(joinedCategoryNames);
    	
    	$('body').find('.wpgmza_infowindow_title').after(p);
    });

    Does that help?

    Kind regards
    – Perry

    #54055
    bigfootjohn
    Member

    Hi Perry,

    This code only works when it is single category. If you use multiple categories it isn’t working. Can you please take a look?

    #54058
    Perry
    Moderator

    Hi John

    Can you please link us to the page which you are experiencing issues with this snippet on?

    Kind regards
    – Perry

    #54064
    bigfootjohn
    Member
    This reply has been marked as private.
    #54107
    Perry
    Moderator

    Hi John

    Can you please use the amended snippet posted earlier in this thread, the code we’re seeing on this site doesn’t match the working snippet posted in this thread.

    Does that help?

    Kind regards
    – Perry

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