Skip Navigation

[Resolved] Map zoom level for 1 marker settings don't work

This support ticket is created 3 years, 1 month 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 3 years ago.

Assisted by: Luo Yang.

Author
Posts
#2195887

I am trying to: change zoom level so that the map doesn't zoom in so far when there is only one marker

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

I expected to see: a change to the zoom level (when only one marker is shown) after changing the settings

Instead, I got: No change to the zoom level

Pick a CESA then a District then one school to see the map zooms so far in that it looks broken

#2196435

Hello,

Thanks for the details, there are two problems:
1) the map is actually not displaying a single marker, but two, you can try these:
- Edit custom field group "School fields":
hidden link
find and edit address field "School Address", enable option "Allow multiple instances of this field"
- Edit each "School" post, in address field "School Address", you should be able to see there are two instances in it

You need to remove the one of the duplicated address.

2) Since you are using AJAX search form, you need to move the map shortcode into the post view, I have setup a demo in your website:
Edit the post view "Instructional Materials Search":
- in section "Loop Editor", line 3, add a map shortcode: [wpv-map-render map_id="map-19" fitbounds="on" single_zoom="12"][/wpv-map-render]
- in section "Loop item in test3", line 8, change the marker's map ID: [wpv-map-marker map_id='map-19' ...]
Edit one school post:
hidden link
Remove one of "School Address" custom field instance
Test it in frontend:
hidden link
It works fine in the new map shortcode.

#2197215

Hi Luo, Thank you for noticing there were multiple instances of the address and for the fix to the map. I'm not sure how the multple address entries happened. I tried to fix this by deleting all the schools and reimporting (after changing the address field to only allow one value). Unfortunately this didn't seem to clear the old data and there are still duplicate addresses. I would really like to avoid having to manually edit 2282 posts. Is there a way clear the old data? Why did deleting the posts completely not do that?

#2198561

You can try to run SQL query to remove those duplicated instances, for example:
hidden link

Please backup your website database first.

#2199183

My issue is resolved now. Thank you!

#2199211

Something must have been cached because now the map is zooming too far in again with only one address for each location. I tried adjusting the code to a smaller zoom number but it doesn't change the result. The map looks broken because it appears as a blank gray box. [wpv-map-render map_id="map-19" fitbounds="on" single_zoom="14"][/wpv-map-render]

#2199303

The credentials you provide above has been removed:
https://toolset.com/forums/topic/map-zoom-level-for-1-marker-settings-dont-work/#post-2195887
Please provide your website credentials in below private message box

I have tried again the problem page with my Chrome browser:
hidden link

I can see the map correctly, please elaborate the question with more details:
I tried adjusting the code to a smaller zoom number but it doesn't change the result

Where and how can I see the problem?

#2199807
#2200219

Please check the URL you mentioned above:
hidden link

There are 6 items(same school post) in the search result, which means there are 6 markers(same address) in the map, it conducts the problem you mentioned above.

#2200683

Okay, that makes sense because the address is on the (parent) school. This must come up fairly often for your users: when you have practitioners that work at the same parent office etc. How do I either tell the map to not show the duplicate markers or otherwise get the map to a zoom level to where it doesn't look broken? I do not want to store the address on the child (curriculum) posts because that is a maintenance issue.

#2201195

It is possible with custom codes, I have done below modifications in your website:
1) Dashboard-> Toolset-> Settings-> custom codes, add one item "remove-duplicated-markers", with below codes:
hidden link

add_shortcode('remove-duplicated-markers', function($atts, $content){
	static $addr = null;
  	
    $atts = shortcode_atts( array(
        'addr' => '',
    ), $atts );
  	$new_addr = do_shortcode($atts['addr']);
  	$res = '';
  	if($addr != $new_addr){
      	$addr = $new_addr;
      	$res = do_shortcode($content);
    }
  	return $res;
});

2) Edit post view "Instructional Materials Search":
hidden link
in section "Loop item in test3", wrap the marker shortcode with above custom shortcode, as below:

[remove-duplicated-markers addr="[types field='school-address' item='@school-curricula.parent'][/types]"][wpv-map-marker map_id='map-19' marker_id='marker-15' marker_field='wpcf-school-address' item='@school-curricula.parent'][wpv-post-link item="@school-curricula.parent"][/wpv-map-marker][/remove-duplicated-markers]

Please test again, check if it is what you want.