无法在JS中显示Google地图

时间:2015-04-09 14:17:36

标签: javascript google-maps google-maps-api-3

作为作业的一部分,我们必须使用Google Map API生成地图并添加客户标记ETC.但是,将此添加到我当前的网页时,它不会生成地图,只会显示下面的屏幕截图。

http://i.gyazo.com/81bccf77e78681f0f9d71c2abe254b58.png

//JavaScript GoogleMaps Manager
window.addEventListener ( 'load', initialise);

//Beginning of Function
function initialise()
    {
        //Specify new variable for lat and long manually
        var latLong = new google.maps.LatLng (53.8319, -2.984547-1.7656)

        //Specify variable for map options
        var mapOptions = 
        {
            center: latLong,
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        //Using DOM to find div in HTML and use it
        var mapContainer = document.getElementById ( 'mapArea' );   
        var map = new google.maps.Map ( mapContainer, mapOptions );
    }   

这是用于生成地图的代码。它在网站之外工作,在它自己的索引文件中没有其他div或代码,但我无法在我必须设计的网站中正确生成它。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

看起来它正在为容器绘制地图,但不知道在哪里拼贴它。

看起来你的latlng电话很奇怪: var latLong = new google.maps.LatLng (53.8319, -2.984547-1.7656)

多久-2.984547-1.7656?最终成为-4.750147

我猜这是问题所在,拉丁语最终会出现在海洋中间,那里没有道路瓦片: Google Map link