Show Category in marker listing instead of address

New home Forums Pro Add-on Show Category in marker listing instead of address

  • This topic has 6 replies, 2 voices, and was last updated 3 months ago by Matthew.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #79918
    van_alex
    Participant

    Dear all,

    is it possible to show the category in the marker listing instead of the adress?

    The map is here: https://map.freo-netzwerk.de/

    What would be perfect, if this could be possible in the marker list on the left side (info panel)

    Title (eg. Akademie für Alte Musik Berlin)
    Category (eg. Kammerensemble) | City (eg. Berlin) [only the city – not the full address. Could also be done with a custom field if necessary].

    Thanks for your help and greetings
    Alex

    #79938
    Matthew
    Moderator

    Hi there,

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

    Unfortunately we currently do not display the category and custom fields in the panel marker listing style, however, you may use some custom JS code to display them accordingly, thus please may you save the below code into the “Custom CSS” setting block (Maps -> Settings -> Custom Scripts), clear your cache and confirm if this helps:

    jQuery(function($){
      $(document).on('markersplaced.wpgmza', function(){
        let map = WPGMZA.maps[0];
        setTimeout(function(){
          $('.wpgmaps_mlist_row').each(function(){
            let row = $(this);
      
            let mid = row.attr('data-marker-id');
            let marker = map.getMarkerByID(mid);
      
            let categories = marker.categories;
      
            let categoriesStringHtml = '';
            for(let cid of categories){
              let category = WPGMZA.categories.getCategoryByID(cid);
              categoriesStringHtml += <code>${category.name},</code>;
            }
    
            categoriesStringHtml = categoriesStringHtml.replace(/,\s*$/, '');
      
            $(<code><div class=&quot;wpgmza-custom-cats&quot;>${categoriesStringHtml}</div></code>).insertAfter(row.find('.wpgmza-title'));
            $(marker.custom_fields_html).insertAfter(row.find('.wpgmza-custom-cats'));
          })
        },500)
      })
    })

    In order to hide the address field in the marker listing, please may you enable the “Hide address field” setting in the settings area (Maps -> Settings -> Marker Listing).

    Once this has been done, please let me know if this helps?

    Kindest Regards,
    Matthew

    #80029
    van_alex
    Participant

    Dear Matthew,

    thanks for your help! You wrote, that I should put the code in the CUSTOM CSS field. Didn’t you mean CUSTOM JS?

    I tried the code in both fields, but non of them worked. At the moment, the code is in the JS field. Can you please check, if there needs something to be changed, to get it work?

    Thanks and best
    Alex

    #80032
    van_alex
    Participant

    … another info:

    we are already using this custom for »jumping back out of zoom«, when clicking back from a selected marker:

    [code]
    jQuery(function($){
    jQuery(‘.wpgmza-close’).on(‘click’, function(){
    WPGMZA.maps[0].setZoom(WPGMZA.maps[0].settings.map_start_zoom);
    WPGMZA.maps[0].setCenter(new WPGMZA.LatLng(WPGMZA.maps[0].settings.map_start_lat,WPGMZA.maps[0].settings.map_start_lng));
    });
    });
    [/code]

    And if I put the new code together with this in the custom code field, the above mentioned does not work anymore.

    #80089
    Matthew
    Moderator

    Hi Alex,

    Thank you for your response, it is much appreciated.

    Yes my apologies for that, I meant the “Custom JS” setting block thank you.

    I have taken a look at the code that I had sent and it appears that our forum system had changed some of the quotes due to the HTML rendering.

    With that said, please find all your custom JS code in my following Gist link: https://gist.github.com/MatthewCodeCabin/94747a638b40cb497e949a2023a9c94f

    Please may you replace your current code with all the code in the above Gist and confirm if this helps?

    Kindest Regards,
    Matthew

    #80092
    van_alex
    Participant

    Dear Matthew,

    perfect, thanks a lot! With your code and some CSS i got it like i wanted it!

    Great plugin, great support!

    Cheers
    Alex

    #80118
    Matthew
    Moderator

    Hi Alex,

    Thank you for getting back to me and most valued time, I tremendously appreciate it!

    I am most happy to hear that, and it was my great pleasure assisting you with this.

    Please may you kindly consider reviewing our plugin at https://wordpress.org/support/plugin/wp-google-maps/reviews/#new-post?

    It would really mean the world to me! And if possible, please could I kindly ask you to mention both your name and mine in the review for administrative purposes as this would be a tremendous help?

    Should you ever require any further assistance, I am more than happy to help.

    Have a fantastic day further!

    Kindest Regards,
    Matthew

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