Title: Google Maps script loading issue in custom plugin meta box
Last modified: August 31, 2016

---

# Google Maps script loading issue in custom plugin meta box

 *  [Cas Dekkers](https://wordpress.org/support/users/casdekkers/)
 * (@casdekkers)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/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](https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder)
   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](https://cms-assets.tutsplus.com/uploads/users/236/posts/21995/image/https%20metabox.jpg).
   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 defer` attributes for 
   the `<script>` tag, but that didn’t solve anything.
 * Thanks for replying!

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/google-maps-script-loading-issue-in-custom-plugin-meta-box/#post-7063603)
 * I think the script is loaded, hidden or not. I think the problem is the map tile
   display is not managed by the browser, it is done by the map script, which thinks
   it already did its job.
 * You probably need to add a listener function to the toggle display triangle that
   explicitly causes the map to redraw the tiles when the display triangle is clicked.
   For example, asking the map to zoom should cause a redraw. You may get a redraw
   just zooming to the current zoom level.
 * All complete speculation on my part, but I’m quite certain that a redraw script
   of some sort needs to execute when the toggle triangle is clicked.

Viewing 1 replies (of 1 total)

The topic ‘Google Maps script loading issue in custom plugin meta box’ is closed
to new replies.

## Tags

 * [hidden](https://wordpress.org/support/topic-tag/hidden/)
 * [load](https://wordpress.org/support/topic-tag/load/)
 * [script](https://wordpress.org/support/topic-tag/script/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/google-maps-script-loading-issue-in-custom-plugin-meta-box/#post-7063603)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
