Google地图无法正常打印

时间:2013-01-10 15:51:06

标签: javascript google-maps

我在通过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);
      }
    });      
  }

有谁可以说出了什么问题?

1 个答案:

答案 0 :(得分:0)

试试这个有效

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

里面的Html标签(div id =“map_canvas”class =“map”)