Google Maps script loading issue in custom plugin meta box
-
Hi all,
I am creating a custom post type plugin for my blog and I’m using the Google Maps Javascript API (v3) to let plugin users specify some location info. To achieve this, I have implemented this example into the HTML section of a meta box. However, I noticed some unwanted behaviour when loading the script while the meta box content is hidden from view.
Please refer to this image. Notice the small triangle in the top right. When you click it, the meta box content (in this case, the “Secure post” and “Secure child post”) gets hidden from view.
Now, when I load my plugin page while the meta box content containing the Maps script is not hidden, everything works like a charm. When I load my plugin page while the meta box content containing the Maps script is hidden, and I proceed to click the small triangle to reveal the map, the entire map is completely greyed out. The autocomplete function (explained in the code sample mentioned above) still works, and the script still puts markers on the ‘map’ (which is now a grey area).
Does anyone know what causes this? I think the script does not get invoked/executed if it is hidden from view. I tried removing the
async deferattributes for the<script>tag, but that didn’t solve anything.Thanks for replying!
The topic ‘Google Maps script loading issue in custom plugin meta box’ is closed to new replies.