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
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.
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?
You can try to run SQL query to remove those duplicated instances, for example:
hidden link
Please backup your website database first.
My issue is resolved now. Thank you!
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]
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?
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.
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.
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.