1

我在通过 JavaScript API V3 打印 Google 地图时遇到了一些问题。问题是地图显示为两部分,地图的顶部和底部部分相互重叠。

代码如下所示:

  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var mapOptions = {
      zoom: 12,
      center: latlng,
      scrollwheel: false,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
    codeAddress();             
  }


  function codeAddress() {
    var address = document.getElementById('address').value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location
        });
      } else {
        alert('Geocode was not successful for the following reason: ' + status);
      }
    });      
  }

谁能说有什么问题?

4

1 回答 1

0

试试这个它有效

.map{
    width: 1000px;
    height: 410px;
    overflow: visible;
    position: absolute;
    background-color: rgb(229, 227, 223);
}   

里面的html标签(div id="map_canvas" class="map")

于 2013-04-17T09:00:04.240 回答