Skip Navigation

[Resolved] Map Not Centering when other parameters specified

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

Problem: I have a Map with a single Marker that is not centering and zooming as expected.

Solution: Use the single_zoom parameter to set a default zoom level when only one Marker is present. The Map will center on that Marker automatically. If the zoom is not working as expected, temporarily delete the problem address from the custom field, then remove the problem address from the Maps cache. Add the address to the custom field again to trigger an update. The following code is formatted for page builders like Divi or WPBakery:

Relevant Documentation:
https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 6 years, 4 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 5 replies, has 3 voices.

Last updated by ChuckGregory 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#957424

I am trying to: display a map based on an address field in a custom post

Link to a page where the issue can be seen: hidden link

I expected to see: a reasonable size map centered on the address of the member

Instead, I got: a map centered in the Atlantic Ocean west of Africa

Here's the code to generate the map. It's in a text module, in a Divi content template for the member post type. Same symptoms in a code module.

{!{wpv-map-render map_id="map-3" fitbounds="off" single_zoom="10" single_center="off"}!}{!{/wpv-map-render}!}{!{wpv-map-marker map_id='map-3' marker_id='marker-3' marker_field='wpcf-address-for-map'}!}{!{/wpv-map-marker}!}
#957931

The attribute single_center="off" cuts off the centering.

I am right that you use the Maps setting "Maps Zoom and Center > Set zoom center and center manually > Force the map center setting even with just one marker", right?
That is the setting that produces fitbounds="off" single_center="off" together.
Then, you should use Coordinates for the map center settings, as you will otherwise have 0,0 as centered location, and the map will not center on a marker.

I think, you should remove those, if you want the map to center on the single marker
I mean, even if there is a marker, we set here that the map should load always, and especially if there is just one marker, on a specific spot.
That cannot zoom in on a marker at any level, which you try to do in the shortcode with single_zoom="10"

Would you agree that the GUI (graphical user interface) actually should not allow to insert those attributes together?
That is where the confusion sources from - it is not supposed to be done, I think.

#957988

Okay, that gets it to center but I can't figure out how to set the zoom. I tried general_zoom and single_zoom. It's coming up zoomed way in and I need to back it out a bit.

#958348

Hi, this code should cause the map to be zoomed out a bit when only one marker is present:

{!{wpv-map-render map_id="map-3" single_zoom="10"}!}{!{/wpv-map-render}!}{!{wpv-map-marker map_id='map-3' marker_id='marker-3' marker_field='wpcf-address-for-map'}!}{!{/wpv-map-marker}!}

If that's not working for you, I'll need to take a closer look. Please provide login credentials in the private fields here and I will see what's happening.

#1020194

Although your fix corrected it on most members, for some reason this one is still broken:
hidden link
Okay I logged into the site and deleted this address in the Member's post editor screen. Then I cleared the address from the Maps cache in Toolset > Settings > Maps, and added the address again in the Member's post editor screen. It's showing up at the correct zoom level now, I believe. Must have been a cache problem.

I tried to take a look at the Content Template created with Divi for the Directory page View, but I'm getting a database connection problem. Since this is a different View and map than the original map centering problem, may I kindly ask you to create a new ticket? This helps us keep the forum organized and helps other users find answers to similar questions. Thanks!

#1021738

Thanks not only for fixing it but also for telling me how, in case I run up against a similar problem in the future.