2013-01-10 54 views
1

我在通過JavaScript API V3打印Google地圖時遇到了一些麻煩。問題在於地圖顯示爲兩部分,地圖的頂部和底部部分相互重疊。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); 
     } 
    });  
    } 

誰能說有什麼不對?

+0

什麼是您的map_canvas提供DIV是什麼樣子?並請發佈「#address」 – Nix

+0

我無法重現您的問題。 – Nix

+0

\t \t \t \t \t

\t \t \t \t \t
\t \t \t – Roman

回答

0

試試這個它的作品裏面

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

HTML標記(DIV ID = 「map_canvas」 的類= 「地圖」)