为什么谷歌地图没有显示出来

Why Google Maps doesn't shown?

本文关键字:显示 谷歌地图 为什么      更新时间:2023-09-26

加载谷歌地图API时出现蓝屏。你能回答一下这些有什么问题吗?

警告消息结果:http://img829.imageshack.us/img829/9279/soru1k.jpg

初始化功能:

            <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
            <script type="text/javascript">
                  function yukle() {
                    var locations = $.parseJSON({$json});
                    alert(locations[0]);
                    var latlng = new google.maps.LatLng(locations[0][1], locations[0][2]);
                    var myOptions = {
                      zoom: 7,
                      center: latlng,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                    var map = new google.maps.Map(document.getElementById("map_canvas"),
                        myOptions);

                  }
        </script>
HTML:

<div id="map_canvas" style="width:620px; height:470px"></div>
CSS:

    <style type="text/css">
        #map_canvas {
        height: 100%;
        }
    </style>

结果是地图上的蓝屏:http://imageshack.us/photo/my-images/546/soru3.jpg/

假设您的页面有元素map_canvas,这应该工作良好。试着发布一些HTML和更多的代码。

同样,试着关闭你页面的css样式。你的css也将样式谷歌地图的东西在你的页面,所以,例如,如果所有的div在你的页面是纯蓝色,它可能会影响谷歌地图元素。

编辑:

根据你给出的截图,很明显地图是正确渲染的。这一行有问题:
var latlng = new google.maps.LatLng(locations[0][1], locations[0][2]);

特别是,latlng没有被正确制作,或者坐标是错误的。你的地图很可能集中在尼日利亚略西的一片海域上(lat:0,lng:0)。

Javascript数组是零索引的。我认为

var latlng = new google.maps.LatLng(locations[0][1], locations[0][2]);

应该是

var latlng = new google.maps.LatLng(locations[0][0], locations[0][1]);