Title: Asynchronously loading Google Map in iFrame with onClick using Java.
Last modified: August 20, 2016

---

# Asynchronously loading Google Map in iFrame with onClick using Java.

 *  [kenneth12345](https://wordpress.org/support/users/kenneth12345/)
 * (@kenneth12345)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/asynchronously-loading-google-map-in-iframe-with-onclick-using-java/)
 * Hi,
 * I wish to load and toggle display a google map on my page only when a user clicks
   a link. That is I do NOT want the maps to load in the background when the page
   loads, but only load when the user requests by clicking the link – Show/Hide 
   map
 * The code below works when for simple URLs, but not for the google map example
   below. It also works when the entire iFrame code as produced by the Google Map
   embed code generator is dumped in the div. Just not when I pull out the src as
   shown here….
 * I have also looked for a plugin to do exactly this…no luck, and also scoured 
   the Google development pages… tried the api… Any suggestions as to why this simple
   rough script will not work as it is with Google Maps, and how to get what I want?
   Please help…
 *     ```
       <a href="#" onClick="javascript:hideshow(document.getElementById('adiv')); loadmap('mapframe');">Show/hide map</a>
   
       <script type="text/javascript">
       function hideshow(which){
       if (!document.getElementById)
       return
       if (which.style.display=="block")
       which.style.display="none"
       else
       which.style.display="block"
       }
       function loadmap(){
       document.getElementById("mapframe").src="http://maps.google.com.au/?ie=UTF8&ll=-32.830735,147.451465&spn=8.655905,14.128418&t=h&z=6&output=embed"
       }
       </script>
   
       <div id="adiv" style="font:24px bold; display: none">
       <iframe id="mapframe" width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src=" "></iframe>
       </div>
       ```
   

Viewing 1 replies (of 1 total)

 *  [MuViMoTV](https://wordpress.org/support/users/muvimotv/)
 * (@muvimotv)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/asynchronously-loading-google-map-in-iframe-with-onclick-using-java/#post-3575044)
 * Did you manage to do that? I have the same issue as you do…

Viewing 1 replies (of 1 total)

The topic ‘Asynchronously loading Google Map in iFrame with onClick using Java.’
is closed to new replies.

## Tags

 * [asynchronous](https://wordpress.org/support/topic-tag/asynchronous/)
 * [iframe](https://wordpress.org/support/topic-tag/iframe/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [map](https://wordpress.org/support/topic-tag/map/)

 * 1 reply
 * 2 participants
 * Last reply from: [MuViMoTV](https://wordpress.org/support/users/muvimotv/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/asynchronously-loading-google-map-in-iframe-with-onclick-using-java/#post-3575044)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
