Category in infowindow

New home Forums Pro Add-on General queries Category in infowindow

This topic contains 23 replies, has 5 voices, and was last updated by  AbelC 2 months ago.

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #51908

    AbelC
    Moderator

    Hi There,

    Thank you so much for sharing this with everyone.

    Please do let us know if there is ever anything else that we can assist you with.

    Kind Regards,
    Abel

    #53958

    bigfootjohn
    Member

    Nevermind.

    • This reply was modified 2 months, 1 week ago by  bigfootjohn.
    • This reply was modified 2 months, 1 week ago by  bigfootjohn.
    #53978

    AbelC
    Moderator

    Hi There,

    Thank you so much for your response.

    Could I kindly ask if there is anything that we can assist you with?

    We will gladly assist with any question or issue you may be having.

    We look forward to hearing back form you.

    Kind Regards,
    Abel

    #53996

    hepqldadmin
    Member

    Hi Abel

    I’ve used the code in this thread to display single and multiple categories for my site and it works great. Thanks for providing this for the original user.

    In addition to this, is it possible to include the word ‘Category:’ before the category value. For instance on my map https://www.hepqld.asn.au/hep-nav/. As an example I’d like the InfoWindow to display the following:

    Sadleirs Pharmacy
    Category: Pharmacy/Chemist
    1 Lannercost St, Ingham, Queensland, Australia 4850
    More details
    Get Directions
    Phone: 07 4776 5777

    Many thanks

    Jessie

    #54004

    AbelC
    Moderator

    Hi There,

    Thank you so much for getting back to me.

    Yes, this can be achieved with custom JS.

    Could I kindly ask if you could please navigate to Maps -> Settings -> Advanced -> Custom JS -> Please replace the previous code with the following JS code below:

    $=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: ' + category.name);
    }
    }
    var joinedCategoryNames = categoryNames.join(", ");
    $('body').find('.wpgmza_infowindow_title').after(joinedCategoryNames);
    }); 

    This should now include “Category: ” before the category value.

    Please do let me know if this is working for you and I look forward to hearing back from you.

    Kind Regards,
    Abel

    #54057

    bigfootjohn
    Member

    Hi again, this code works perfectly when it is single category. If you’ve multiple categories it isn’t working. Can you have a look please?

    #54065

    AbelC
    Moderator

    Hi There,

    Thank you so much for letting me know.

    It appears that the system removed some code. My sincere apologies for the inconvenience.

    Please find the txt file attached.

    Could I kindly ask if you could please navigate to Maps -> Settings -> Advanced -> Custom JS -> Please replace the previous code with the following code in txt file attached.

    Please do let me know if this is now working for you and we look forward to hearing back from you.

    Kind Regards,
    Abel

    • This reply was modified 2 months ago by  AbelC.
    Attachments:
    You must be logged in to view attached files.
    #54071

    bigfootjohn
    Member

    Hi again,

    It writes “Category: Beach Category: Town. I want: Category: Beach, Town

    #54126

    AbelC
    Moderator

    Hi There,

    Thank you so much for getting back to me, and my sincere apologies for the inconvenience and delayed response over the weekend.

    I have now made a couple of changes to the code.

    Please find the txt file attached.

    This should now display the text “Category:” and then display your categories in the InfoWindow.

    Please do let me know if this is working for you.

    Kind Regards,
    Abel

    Attachments:
    You must be logged in to view attached files.
Viewing 9 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic.