加载Google地图问题

时间:2016-01-31 01:34:26

标签: html css google-maps

我正在寻找Google地图的一些帮助 - 我觉得我已经尝试过通过Google找到的大多数修补程序。一个特别建议父母div (class="findus__gm--small")需要一个高度和宽度 - 没有工作。

我将代码从以前成功运行的项目中删除。我看不出任何差异。

有什么建议吗?

<div class="main-content__info"> <!-- small google map and open hours-->
                    <div class="findus__small"> 
                        <div class="findus_small_gm_text"> <!-- small google map text-->
                            <h4 class="title__marginbtm"><span class="title--underline">Where to find us</span></h4>
                            <p class="lh--200">Based in Yeadon, you can find us just off of "Kirk Lane", on the corner of "Whack House Lane". Bus stops are just a 5 minute walk away, with services running regulerally. Please note, street parking is limited. </p>
                        </div>
                        <div class="findus__gm--small"> <!-- small google map-->
                            <div id="googleMap"></div>
                        </div>
                    </div>
                    <div class="openhours"> <!--open hours table -->
                    </div>
                </div>

.findus__gm--small {
    height: 10em;
    margin-top: 2em;
    width: 100%;
}

#googleMap {
    height: 10em;
    width: 100%;
}

    var location= new google.maps.LatLng(53.8659011,-1.6932696);
        function initialize() {
            var mapProp = {
                center:location,
                zoom:17,
                mapTypeId:google.maps.MapTypeId.ROADMAP
            };
            var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
            var marker=new google.maps.Marker({ 
                map:map,
                position:location,
                animation:google.maps.Animation.BOUNCE
            });
            marker.setMap(map);
            var infowindow = new google.maps.InfoWindow({
  content:"66 Whack House Lane, Yeadon, Leeds, LS19 7LY"
  });

google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
  });
}
    google.maps.event.addDomListener(window, 'load', initialize);
});

$(window).load(function() {
    $('#slider').nivoSlider(); 
    effect:'random'
});

2 个答案:

答案 0 :(得分:1)

这是因为您使用了谷歌地图保留的关键字&#34;位置&#34;作为变量,为了使谷歌地图工作,您应该将var位置更改为其他单词。更正的js是: -

<script type="text/javascript"  src='https://maps.googleapis.com/maps/api/js?v=3.exp&#038;signed_in=true&#038;ver=4.4.1'></script>

<script>
var LatLng= new google.maps.LatLng(53.8659011,-1.6932696);
        function initialize() {
            var mapProp = {
                center:LatLng,
                zoom:17,
                mapTypeId:google.maps.MapTypeId.ROADMAP
            };
            var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
            var marker=new google.maps.Marker({ 
                map:map,
                position:LatLng
            });
            marker.setMap(map);
            var infowindow = new google.maps.InfoWindow({
              content:"66 Whack House Lane, Yeadon, Leeds, LS19 7LY"
              });

            google.maps.event.addListener(marker, 'click', function() {
              infowindow.open(map,marker);
              });
        }
        google.maps.event.addDomListener(window, 'load', initialize);

        </script>

答案 1 :(得分:0)

解决了:

不完全确定如何,但从一开始(再次)开始并遵循Google开发教程似乎已经修复了它。

某处一定是个愚蠢的错误。

感谢所有建议。