2015-12-07 84 views
-1

我正在尝试将谷歌地图合并到我正在开发的网页中。我想要在选项卡控件的选项卡#5上显示地图。当我的代码运行时,选项卡#5填充完全灰色的背景,左下角的Google徽标,缩放和平移控制,但没有其他。没有地图数据,街道,选项卫星视图等谷歌地图插件 - 显示控件但不显示数据

下面是我在做什么...... 我,包括谷歌的JS文件...

https://maps.googleapis.com/maps/api/js 

的实际代码本身是...

var map; 
function initMap() { 
    console.log('Console running 5') ; 
    map = new google.maps.Map(document.getElementById('analysisTabMap'), { 
    center: {lat: -34.397, lng: 150.644}, 
    zoom: 16, 
    zoomControl: true, 
    scaleControl: true 
    }); 
} 


    initMap(); 

控制台显示'Console running 5;消息,所以我的代码正在执行。我认为这可能是一个缩放因素,所以我已经放大和缩小;但我仍然只看到灰色。

我在做什么错?这是我的标签显示... enter image description here

+0

请提供[最小的,完整的,经过测试和读示例](HTTP:// stackoverflow.com/hel p/mcve),证明了这个问题。 – geocodezip

回答

0

好像你的代码工作得很好。 难道是你的页面上的另一个脚本导致一个错误,打破地图的加载?

http://jsfiddle.net/zvjr80w3/

HTML

<div id="analysisTabMap"></div> 

CSS

#analysisTabMap { 
    width: 100%; 
    height: 500px; 
} 

的Javascript

var map; 
function initMap() { 
    console.log('Console running 5') ; 
    map = new google.maps.Map(document.getElementById('analysisTabMap'), { 
    center: {lat: -34.397, lng: 150.644}, 
    zoom: 16, 
    zoomControl: true, 
    scaleControl: true 
    }); 
} 


initMap();