2014-06-13 82 views
-2

我的谷歌地图在Firefox和IE中正常工作。但是当通过chrome加载时,地图将位于顶部。它似乎也像所有的代码功能工作正常 我发现 margin-top:-400px;/地图位置/ margin-left:-400px;/地图位置/ 工作在Firefox中查找,但在镀铬的作品是我的代码太顶部 部分内容如下:铬和FF显示“边缘顶”不同

<style> 
BODY { 
font-family : Verdana,Arial,Helvetica,sans-serif; 
color: #000000; 
font-size : 13px ; 
background-color:#8ba4d9; 
} 
#map_canvas { 
width: 300px; 
height: 300px; 

box-shadow: 1px 5px 5px #666; 

position:absolute; 
left:50%; 
top:50%; 

margin-top:-400px; /*map position*/ 
margin-left:-400px; /*map position*/ 
} 
</style> 
<script type='text/javascript'> 
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
</script> 
<div id="map_canvas" align="center" style="width:65%; height:90% ; position: relative;"></div> 

回答

0

试试这个脚本

的google.load( '可视化',' 1',{'packages':['geomap']}); google.setOnLoadCallback(drawMap);

function drawMap() { 
    var data = google.visualization.arrayToDataTable([ 
    ['Country', 'Popularity'], 
    ['Germany', 200], 
    ['United States', 300], 
    ['Brazil', 400], 
    ['Canada', 500], 
    ['France', 600], 
    ['RU', 700] 
    ]); 

    var options = {}; 
    options['dataMode'] = 'regions'; 

    var container = document.getElementById('map_canvas'); 
    var geomap = new google.visualization.GeoMap(container); 
    geomap.draw(data, options); 

};

具有u加https://www.google.com/jsapi'>到你的页面(这个脚本是很重要的)

+0

喜aashi,我有尝试你的代码,但它显示的不同在fifrefox和chrome – andrewarnier

+0

@aashi:问题是关于Google Maps JavaScript API,请参阅'new google.maps.Map()',您正在回答Google Visualization API的解决方案。 –