change zoom level of marker

New home Forums Pro Add-on General queries change zoom level of marker

Tagged: ,

This topic contains 36 replies, has 7 voices, and was last updated by  sawmri 6 months ago.

Viewing 8 posts - 31 through 38 (of 38 total)
  • Author
    Posts
  • #48309

    sawmri
    Member

    Figaro-

    Awesome! That works perfectly. Thank you very much!

    #48314

    Dylan
    Moderator

    Hi there,

    My apologies for the delay in response.

    So glad to hear this has been resolved. Please do let me know if you need anything else moving forward.

    Have a great week further!

    Kind Regards,
    Dylan Auty

    #50132

    cameron.m
    Member

    I have tried all of this code and it doesnt work.

    I have cleared my browser and server cache, tried multiple browsers.

    WHen I look at source code in console, the code is there inside the wpgmza_open_marker_func function, but nothing occurs on click of a marker.

    The info window is opening but none of the added code will work.

    • This reply was modified 6 months, 1 week ago by  cameron.m.
    #50157

    Dylan
    Moderator

    Hi there,

    Thank you for getting in touch. Please provide me with a link to your site so that I can confirm if the code is running on the website?

    It is possible that a conflict or a different version number of the base plugins may be the cause of the code not working on your site.

    I look forward to hearing back from you and working through this with you.

    Kind Regards,
    Dylan Auty

    #50242

    sawmri
    Member

    Cameron-

    The support team is excellent. I am sure they will help you promptly.

    If it helps, here are the scripts we entered for our site, after a lot of trial and error:

    Custom CSS

    .wpgmza_map img { max-width:none; }
            .wpgmza_widget { overflow: auto; }
    .gm-style-mtc {
    display:none;
    }
    
    #wpgmza_filter_8 {
    position: relative;
    bottom: calc(-434px - 1em);
    z-index: 999;
    left: 8%;
    }
    
    @media only screen and (max-width: 825px) {
    #wpgmza_filter_8 {
    position:inherit
    }
    }
    
    .dataTables_length
    {
     display: none;
    }
    
    .wpgmza_map
    {
    	margin-bottom: 1em;
    }
    
    #wpgmza_filter_8 {
    	display: inline-block;
    }
    
    @media only screen and (max-width: 768px)
    {
    .wpgmza_map
    {
    position: relative;
    top: 20px;
    margin-bottom: 40px;
    }
    }
    

    and custom JS

    function myFunction(x) {
      if (x.matches) { // If media query matches
        jQuery(function($) {
    $(window).on("load", function(event) {
    WPGMZA.settings.marker_listing_item_click_scroll_offset = 6;
    });
    });
      } else {
       jQuery(function($) {
    $(window).on("load", function(event) {
    WPGMZA.settings.marker_listing_item_click_scroll_offset = 150;
    });
    });
      }
    }
    
    var x = window.matchMedia("(max-width: 1024px)")
    myFunction(x) // Call listener function at run time
    x.addListener(myFunction) // Attach listener function on state changes
    jQuery("body").on("click", ".wpgmaps_mlist_row, .wpgmaps_blist_row", function(event) {
    var wpgmza_mapid = jQuery(this).attr("8");
    setTimeout(function(){
    WPGMZA.getMapByID(wpgmza_8).setZoom(13);
    }, 300);
    });
    
    window.onload = function(){
    if(typeof WPGMZA !== 'undefined' && typeof WPGMZA.maps !== 'undefined'){
    	for(var mapid in WPGMZA.maps){
    		var modMap = WPGMZA.maps[mapid];
    		for(var i in modMap.markers){
    			var mark = modMap.markers [ i ] ;
    			mark.on('click', function(){
    //add the following line to centre marker
    				modMap.panTo(this.position); 
    				modMap.setZoom(14);
    			});
            }
        }
    }
    };
    
    jQuery(window).load(function(){
      if(wpgmaps_localize != null && typeof wpgmaps_localize !== "undefined"){
        if(jQuery(window).width() < 481){ 
          	for(var entry in wpgmaps_localize) { 
              MYMAP[entry].map.setZoom(parseInt(wpgmaps_localize[entry]['map_start_zoom'])-2);
          	} 
        } 
      } 
    });

    Finally, if I recall correctly, you might have to check the formatting for curly quotes, which we had to figure out, should be straight quotes (if I recall correctly).

    I hope this is helpful from a user’s viewpoint!

    #50243

    cameron.m
    Member

    Thanks for the reply. I actually got this working with the following code in the Custom JS section as per this thread:

    jQuery(function ($) {
          $(window).on("load", function (event) {
                WPGMZA.settings.marker_listing_item_click_scroll_offset = 150;
                if (typeof WPGMZA !== 'undefined' && typeof WPGMZA.maps !== 'undefined') {
                      for (var mapid in WPGMZA.maps) {
                            var modMap = WPGMZA.maps[mapid];
                            for (var i in modMap.markers) {
                                  var mark = modMap.markers[i];
                                  mark.on('click', function () {
                                        modMap.panTo(this.position);
                                        modMap.setZoom(15);
                                  });
                            }
                      }
                }
          });
    });
    #50244

    sawmri
    Member

    Glad to hear you figured it out!

    #50262

    Dylan
    Moderator

    Hi there,

    So glad to hear you managed to get this working as intended.

    Thank you for sharing your solution, this is a tremendous help to the rest of the community.

    Have a great day!

    Kind Regards,
    Dylan Auty

Viewing 8 posts - 31 through 38 (of 38 total)

You must be logged in to reply to this topic.