views:

58

answers:

1

hi friends,

how to set google map in the centre of a small <div>?

below is the code

below code is working fine but the city is display in the top corner of the <div>

how to move that in the center of <div>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Google Map</title>
    <script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=true&amp;amp;key=ABQIAAdsfdspeATWBO-DG9lMgJ0ShhR6-O8wdUc0uGLMinc7m1CWtOdsfdsfsdqG9fPRwilSPzZoK_0Q" type="text/javascript"></script>    
<script type="text/javascript">
function showLocation(address)
  {
   var map = null;
    var geocoder = null;
      if (GBrowserIsCompatible()) {
  var map = new GMap2(document.getElementById("map_canvas_small"));
  geocoder = new GClientGeocoder();

     if (geocoder) {
          geocoder.getLatLng(
            address,
            function(point) {
              if (!point) {
                alert(address + " not found .");
              } else {
                  map.setCenter(point , 13);
              }
            }
          );}

      }
    }
</script>

    </head>

    <body onunload="GUnload()">
    <div id="map_canvas_small"  style="width: 208px; height:80px "></div>
                  <script type="text/javascript">
  {
  showLocation('Madrid, Spain');
  }
  </script>
    </body>

    </html>
+1  A: 

What browser do you use? I test your code in different browser and have normal centering. Perhaps the problem is browser or OS?

DreamWalker
me using internet explore...
Alex
@Alex, try to test you code on another computers
DreamWalker