Zoom level on mobile

New home Forums Pro Add-on Troubleshooting Zoom level on mobile

Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #69328
    dynafish
    Participant

    Hi

    Thanks for a fantastic plugin 🙂

    If pssible I would like a different zoom level on mobile and desktop. I did find a possible fix here:

    Map in not responsive at all

    but this dates from 2018, and when I look at core.js I see:

    // NB: Redundant as of 8.1

    so I’m guessing that this fix is not now relevant…? Do you have an alternative I could use? Could I put code into a page template?

    I did try the “Fit map bounds to markers” setting, but as this puts the markers right at the very edge of the screen, it’s not a good solution for us. Would it be possible to pad the map to enable the extreme markers to be set in from the bounds?

    #69334
    Steven
    Moderator

    Hi @dynafish,

    Thank you so much for getting in touch, we really appreciate your time.

    Just to confirm, you would like to apply different zoom levels depending on whether the visitor is on mobile or desktop?

    If so, the following snippet should help to achieve this:

    
    jQuery(function($){
    	if( /Android|webOS|iPhone|iPad|Mac|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
    		jQuery(document.body).on("init.wpgmza", function (event) {	
    			var mobileZoom = 13;
    
    			WPGMZA.maps[0].setZoom(mobileZoom);
    		});
    	}
    });
    

    Kindly set your map zoom to the desired zoom for desktop and then apply the above custom JS to the custom JS field via Maps -> Settings -> Advanced Settings -> Custom JS.

    Simply adjust the mobileZoom = 13; to a level between 1 and 21.

    Kindly let me know if this helps?

    I look forward to hearing back from you.

    Kindest Regards,
    Steven de Beer

    #69393
    dynafish
    Participant

    Hi Steven

    Excellent, that works a treat, thank you 🙂

    David

    #69394
    Steven
    Moderator

    Hi David,

    Thank you so much for getting back to me.

    I am glad to hear this has helped. 🙂

    Please do let me know if you have any other issues or questions as I am always eager to assist.

    If you ever have two minutes spare, please consider reviewing the plugin on https://wordpress.org/support/plugin/wp-google-maps/reviews/#new-post it would mean the world to me! (If possible, could I ask you to mention both your name and mine in the review for administrative purposes, this would be a tremendous help!)

    Do have a fantastic week further!

    Kindest Regards,
    Steven De Beer

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