New home › Forums › Pro Add-on › Troubleshooting › Zoom level on mobile
- This topic has 3 replies, 2 voices, and was last updated 1 year, 9 months ago by Steven.
-
AuthorPosts
-
June 7, 2021 at 5:23 pm #69328dynafishParticipant
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?
June 8, 2021 at 10:27 am #69334StevenModeratorHi @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 BeerJune 10, 2021 at 12:35 pm #69393dynafishParticipantHi Steven
Excellent, that works a treat, thank you 🙂
David
June 10, 2021 at 12:43 pm #69394StevenModeratorHi 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 -
AuthorPosts
- You must be logged in to reply to this topic.