Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7847377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:52:31+00:00 2026-06-02T17:52:31+00:00

This is a drop down Div – which works with everything except GoogleMap. I

  • 0

This is a drop down Div – which works with everything except GoogleMap.

I get half the map showing or maybe a 1/4 of it… When I get rid of the div’s all works fine… Or is there a workaround without div’s? Ideas… I tried declaring table, p etc… No luck…

Javascript Drop Down Code and Div calls

   <script type="text/javascript">
   function showElement(layer){
   var myLayer = document.getElementById(layer);
   if(myLayer.style.display=="none"){
   myLayer.style.display="block";
   myLayer.backgroundPosition="top";
   } else { 
   myLayer.style.display="none";
   }
   }
   </script>

  <div class=catlist>
  <table border=0 cellpadding=4>
  <tr>
  <td valign=middle><img src="images/plus.png" onclick="javascript:showElement('ed')"></td>
  <td valign=middle><a href="#" onclick="javascript:showElement('ed')"><b>Edit GPS 
  Map</b></a></td>
  </tr></table>
  </div>
  <div class="qlist" id="ed" style="display:none;">

  <div id="map" style="width: 500px; height: 250px;"></div>

  </div>

Adding the Google Javascript…

This is the actual Google Maps Javascript…
Cold Fusion Plots the # markers…
This works fine outside of divs…
Code suggested above works to display the correct map interface…
But the centering of the plot is not working…
And marker shows at top left corner with above code provided…

  <div id="map" style="width: 500px; height: 250px;"></div>
  <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript">
  </script> 

  <script type="text/javascript"> 

  var locations = [ 
["#bsname#", #gpslat#, #gpslong#, #busid#], 
  ]; 

  var map = new google.maps.Map(document.getElementById('map'), { 
  zoom: 15, 
  center: new google.maps.LatLng(#gpslat#, #gpslong#), 
  mapTypeId: google.maps.MapTypeId.ROADMAP
  }); 

  var infowindow = new google.maps.InfoWindow(); 

  var marker, i; 

  for (i = 0; i < locations.length; i++) {   
  marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
    map: map 
  }); 

  google.maps.event.addListener(marker, 'click', (function(marker, i) { 
    return function() { 
      infowindow.setContent(locations[i][0]); 
      infowindow.open(map, marker); 
    } 
  })(marker, i)); 
  } 

</script>    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:52:33+00:00Added an answer on June 2, 2026 at 5:52 pm

    The changes I made were:

    • triggering a resize when the div is expanded
    • centering the map after the resize
    • making map and locations variables global.

    The jsfiddle is here:

    http://jsfiddle.net/Mgp9z/9

    <!DOCTYPE html>
    <html>
      <head>
        <style type="text/css">
          html, body, #map_canvas { margin: 0; padding: 0; height: 100% }
        </style>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
    var map;
          var mapOptions = { center: new google.maps.LatLng(0.0, 0.0), zoom: 2,
            mapTypeId: google.maps.MapTypeId.ROADMAP };
    
    // CHANGED locations and map now global so they refer to the same thing in both initialize and showElement
    
    var locations = [ 
    ["a", 40.2, -88.8, "k"], 
      ]; 
    
    var map;
    
    function initialize() {
       map = new google.maps.Map(document.getElementById('map'), { 
      // CHANGED
          zoom: 10, 
      center: new google.maps.LatLng(40.2, -88.8), 
      mapTypeId: google.maps.MapTypeId.ROADMAP
      }); 
    
      var infowindow = new google.maps.InfoWindow(); 
    
      var marker, i; 
    
      for (i = 0; i < locations.length; i++) {   
      marker = new google.maps.Marker({ 
        position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
        map: map 
      }); 
    
      google.maps.event.addListener(marker, 'click', (function(marker, i) { 
        return function() { 
          infowindow.setContent(locations[i][0]); 
          infowindow.open(map, marker); 
        } 
      })(marker, i)); 
      } 
    
          }
    function showElement(layer){
       var myLayer = document.getElementById(layer);
       if(myLayer.style.display=="none"){
       myLayer.style.display="block";
       myLayer.backgroundPosition="top";
    
       // *** add the trigger here ***
       google.maps.event.trigger(map, 'resize');
       var mylat=locations[0][1];
       var mylng=locations[0][2];
       map.setCenter(new google.maps.LatLng(mylat,mylng));
    
       } else { 
       myLayer.style.display="none";
       }
    }
    
          google.maps.event.addDomListener(window, 'load', initialize);
        </script>
      </head>
      <body>
    <div class=catlist>
      <table border=0 cellpadding=4>
      <tr>
    Lat:   <input type="text" id="mylat" value="40.2">
    Lng:   <input type="text" id="mylng" value="-88.8">
          <!-- <td valign=middle><img src="images/plus.png" onclick="javascript:showElement('ed')"></td> -->
      <td valign=middle><a href="#" onclick="javascript:showElement('ed')"><b>Edit GPS 
      Map</b></a></td>
      </tr></table>
      </div>
      <div class="qlist" id="ed" style="display:none;">
    
      <div id="map" style="width: 500px; height: 250px;"></div>
    
      </div>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which can display drop down in div tag of html.
So I have this code: jQuery('div[class=someClass] :input:not(:button)').each(function() { if (input type is drop-down) {
I have 2 div tags which emulate a drop-down menu. When the outer div
For example, if I have this HTML for a drop down menu: <div data-role=fieldcontain>
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have this drop-down list of countries: <select name=country> <option value=>Country...</option> <option value=Afganistan>Afghanistan</option> <option
I have capture change event on drop down select. This drop down field is
I'm working on drop down menus for this: http://www.heroicdreams.com/wordpress/elderFlashSite.html In every other browser it
I wrote this little function to fill a drop down list with data from
I'm using this codes for listing custom field values into drop-down list element on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.