Skip Navigation

[Resolved] Default Initial Zoom Level for Map Inserted as block for a view

This thread is resolved. Here is a description of the problem and solution.

Problem: I have set my map initial zoom level to center and zoom in to show all the markers, but when I display the map the initial zoom level is zoomed out showing the entire global map.

Solution: In this case the map is not displayed when the page is loaded, so the initial zoom level calculations are inaccurate. You must trigger a map reload function when the map is displayed to calculate the initial zoom level correctly. The correct function to call is:


Place that code after the code used to turn on the map display, and replace map-id with the ID of your map.

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 2 voices.

Last updated by Don 2 years, 11 months ago.

Assisted by: Christian Cox.



Tell us what you are trying to do?

I followed the instructions for adding a map to a page (archive) with a view as source for the map markers. I set the settings for "adjust zoom and center to show all markers at once", which I assume is intended to achieve the same as "fitbounds" enabled with a shortcode.... but on my map for the archive view, although ALL listings are in the same general area (neighboring states), the intial map renders as a narrow, full width panorama of the earth, with my "marker cluster" centered all alone in the center..... so definitely not automatically zoomed in close as possible with all markers still in the frame. Not sure what i am missing, since set it up as a block, which is convenient for sure, i cant manually edit the shortcode and aside from that setting i dont see anything that would have an impact or make it start out so zoomed out unnecessarily......


Usually the setting "Adjust zoom and center to show all markers at once" is sufficient to zoom into a reasonable level to show all the markers at once when the map loads if the map is displayed without marker clustering. If marker clustering is enabled, there is another setting you can use to adjust the maximum zoom level where clustering is allowed. You can try that and see if it changes the initial display like you'd expect.

Otherwise, you can try some troubleshooting steps:
- Try adjusting the map height and width using set pixel values to see if this influences the initial zoom level
- If there are other maps on the same page, ensure the map IDs are all unique so there are no conflicting configurations
- Be sure there are no incomplete or invalid map marker configurations in the map block sidebar. Remove any markers that are not completely configured.

If you're not able to get the results you expect, please provide a URL so I can see what is happening.




i played with map height and width, no effect.
there is only one map assigned to the archive view.
there is only one map marker assigned to the map.

No change....

The site is being worked on with a maintenance mode for not logged in users, if there is a secure form i can give you front end login info and a link. dont laugh though, site migration and transition to wordpress/toolset is still rough looking haha.


Okay sure, I can log in and take a closer look. Private reply fields are enabled here so you can share login information securely. Please let me know where to find the map that is displayed incorrectly.



oops, that wasnt private. i dont think full wp admin or ftp access is necessary here, just wanted to provide standard user login info and the link to see the issue but that posted as a normal post apparently....


I'll activate a different set of private reply fields this time with some free text areas where you can share standard login information. You can add dummy information if necessary to any required fields.

Screen Shot 2021-06-16 at 11.59.48 AM.png

Aha, the map is not displayed when the page is initially loaded. I have to click the "map" button to toggle the map display mode. The hidden map is part of the problem here, because the Maps plugin attempts to calculate the optimum zoom level during the map initialization process. Those calculations rely on the map dimensions, which are ambiguous until the map is actually displayed. If I trigger the Maps reload_map function in the browser console after the map is displayed, the zoom level changes to something more like what I would expect to see (screenshot):


So my first suggestion is to use that code to re-trigger the zoom level calculations after toggling to "map" display mode. I found some event handler code for the radio input, where I think you could call the reload_map function like so:

        var inputValue = jQuery(this).attr("value");
        var targetBox = jQuery("." + inputValue);

You could add some conditional logic in there if you'd like to call the function only in map display mode, but it should not cause any JS error if you leave the code as-is. Let me know if this doesn't solve the problem and I can take a closer look.



Fantastic! that looks to have fixed the issue indeed. Many, many thanks and am glad it was a "small" but important thing that with your expertise was easy enough to notice and fix. My issue is resolved now. Thank you!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.