Support Forum
Support › MB Geolocation › OSM map does not render fully when the field has conditional logic
Hi,
I created a Open Street Maps field, with id: on_site_location_osm
I set the 'address' field to: 'address'.
I created a text field, with
id: 'address'
label: 'text'
On the front all works: the map tiles in view render nicely, and when I type in the text field, and click on the autocomplete suggestion, the pin changes and the map renders all tiles in view again.
When I add conditional logic to these fields, The tiles don't all render, and when I type out an address in the text field and click on the autocomplete suggestion, although the pin changes to that new location, the map tiles do not render (except for a few tiles on the side).
Why? How do I ensure that the osm map and address text renders well, with conditional logic? This is a must for my use case scenario. Thanks!
sorry @ last sentence i meant 'How do I ensure that the osm map renders well even when using conditional logic?' There's nothing wrong with the address text field itself.
the osm map also does not render tiles when osm and text fields are put in a group that has conditional logic. without conditional logic it's fine... .
Hello John,
I think the conditional logic setting isn't correct so it will break the Javascript code and cause the issue with the map which will use some Javascript to display the map in the front end.
Please export the field group to a JSON file and share it here https://docs.metabox.io/extensions/meta-box-builder/#export--import
I will help you investigate the issue.
Hi Peter!
Thanks for being here and helping out. I must say that I've used conditional logic many times in my field group. They all work - I think that the conditional logic is set up good, too. As soon as I take away conditional logic, it renders properly. Weird.
Having said that; my custom fields group is quite large... it is 8482 lines. Also, there is sensitive information there, I would rather not have that visible here. Could I share in another way? Feel free to reach out to me through my account email if needed.
There is another issue going on, too. I made a separate topic about it here (https://support.metabox.io/topic/custom-fields-broken/). It seems I have reached some sort of limit in terms of custom fields group. I can't add more fields, and the post type my custom field group is associated with always defaults back to the standard WordPress 'post' post type. As a matter of fact, I can't even set geo = true in the custom settings of the field group. Clicking 'update' doesn't change that.
At the moment I can't continue working on my field group... . Thanks for any help.
Hello John,
I believe this issue is solved after you increase the PHP setting max_input_vars as in another topic https://support.metabox.io/topic/custom-fields-broken/
I'm waiting for your feedback.
Dear Peter, I thank you for this message. Actually, no it is not resolved :D. I was able to continue finishing my complete custom fields group (by increasing the max_input_vars), but now am coming back to all sorts of challenges I still have. I will try once more to go through your suggestions here and will update.
The Open Street Map field and the text field starting with 'address' for its ID is a subgroup of a group. I tried moving them one level up (so that they were no longer a subgroup of a group, but just a group). This didn't help. The tiles still do not render well.
I tried taking both fields out from group level to just be unnested fields (so not under any group). This also did not help. The tiles still do not render well.
The conditional logic itself is set up correctly: the osm field and the text field both should only become visible if another field, a 'work setting' field (select field type) is set to the value 'on-site'. The conditional logic in itself is working correctly: the osm and address field show when intended. But the conditional logic somehow produces the side effect that the tiles of the OSM do not load properly. The majority remains not rendered. When I move the map around with my mouse, some of the new tiles that come into view do render. Most do not. Zooming in and out on the map also leads to some tiles rendering, others (most) won't load. Entering the address also produces the same behaviour.
When the conditional logic is turned off, the tiles do load properly. However this can't be the solution: I really do need the map and address field to show only when the other field is set to 'on-site'.
This behavior is confirmed to not have to do anything with the max_input_vars, because since our last exchange of thoughts I have increased the max_input_vars and the whole custom group has now become larger....
I can't share the entire custom fields group here though...
What could be the problem here?
I am one step closer to identifying the issue. It has something to do with the screen size and browser?
By default I work from a laptop and my browser window is typically not maximized (I work with multiple windows side by side).
When I go to the page that has the front-end user submission form on it, and I go through the custom fields group, and then the open street map is triggered to show due to conditional logic, the behaviour is as I describe.
HOWEVER, in this situation when I then maximize my browser window, the map tiles do all load as they should and the map just works how it should. No issues whatsoever.
But then again, when I start with my browser window *maximized*, and I go to the page and then trigger the conditional logic to show the open street map, the same issues show as I described! When I resize the browser window .... the issues disappear!
As a matter of fact: the starting situation is not important: when the open street map loads, I just need to change the size of the browser window a bit, or maximize/undo maximize, then the tiles all load perfectly fine.
I am using Brave browser on my laptop, but the behaviour is the same on a Chrome browser, Firefox browser and Duckduckgo browser!
Similar experience on a mobile phone. When goingto the page from my mobile phone, using chrome, the issues show. But if I then swap to another app from the browser, and then open back the chrome browser with the osm map, all the sudden the problems are not there and the map loads just fine.
What could this mean? This behaviour should not show.
Changing the PHP to a version 7.4 did not help either.
Hello John,
Can you please share a screen record of the issue and share the page URL where I can see that?
Hi Peter, can I please do that through the contact form? Thank you
Yes, please. You can share the sensitive information via the contact form https://metabox.io/contact/
Thank you!