click on list of markers at bottom of map gives zoomed in view. Map as well?

New home Forums Pro Add-on General queries click on list of markers at bottom of map gives zoomed in view. Map as well?

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

    if you click on a marker in the list at the bottom of map it gives a zoomed in view on the map. Can this apply to the markers on the map as well?

    TIA

    Bill

    #23813
    Dylan
    Moderator

    Hi Bill,

    Thank you so much for getting in touch with us.

    Yes this could be applied to the markers on the map, however it would require a few code changes.

    Are you comfortable with making code changes such as this one? I would then be able to guide you through the steps.

    Alternatively, I could make these changes on your behalf if you prefer? 🙂

    #23816

    Thanks,

    No I am happy ( and actually enjoy!) doing code changes. My concern is doing changes and updates are applied – losing whats been done. However lets have a go …

    TIA

    Bill

    #23832
    Dylan
    Moderator

    Hi Bill,

    Not a problem at all, please find the steps below:

    1. Open the core.js file (wp-google-maps-pro/js/core.js) and look for the following segment of code:

    if (click_from_list) {
       MYMAP[map_id].map.panTo(marker.position);
       MYMAP[map_id].map.setZoom(13);
    
    click_from_list = false;

    2. There will be more than on instance of the code above (the second instance will be relatively close to the first and should be easy to fine) – I would suggest looking at lines 2756 to 2779 Approx.
    3. Replace both instances with the following instead:

    MYMAP[map_id].map.panTo(marker.position);
    MYMAP[map_id].map.setZoom(13);

    4. Save the file with the changes in place.

    This should have the desired effect.

    I hope this helps? Unfortunately updates will revert any changes applied to the code.

    #23841

    Excellent,

    Just need to know how to zoom back out to the default zoom level. Am I missing something or should I stick a button somewhere to do this?

    Thanks again

    Bill

    #23845
    Dylan
    Moderator

    Hi Bill,

    To alter the zoom level to a different level you could use the following code:

    MYMAP[map_id].map.setZoom(13);

    Where 13 could be set to your preferred ‘reset’ zoom level.

    However you will then most likely need to add a button to your site which triggers the code above.

    I hope this helps?

    #23847

    I see… So if I wanted a ‘return’ button set in the info marker window to take me back to the original default map / zoom where would I code this up?

    Bill

    #23852
    Dylan
    Moderator

    Hi Bill,

    I would recommend adding a simple link tag such as the one below: (Add this to your info-window)

    <a href="#wpgmza_map_1" class="my_reset_button">Return</a>

    With this is place you could add the following jQuery to your site:

    jQuery('body').on('click', '.my_reset_button', function(){
      for(var entry in MYMAP) {
        if(typeof MYMAP[entry]["map"] === "undefined" || MYMAP[entry]["map"] === null){
         InitMap(wpgmaps_localize[entry]['id'],'all',false);
        }
      }
    });

    This could be added to our core.js file (wp-google-maps-pro/js/core.js) below the following line:

    jQuery(document).ready(function(){

    I hope this helps?

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