gpt4 book ai didi

javascript - Google map - 不显示但以 HTML 形式加载

转载 作者:行者123 更新时间:2023-11-28 14:03:51 24 4
gpt4 key购买 nike

我不知道这是为什么。

但是由于某种原因,我的谷歌地图脚本加载到页面中,但没有显示。

我很好奇我做错了什么。

这是我的 html。

<ul class="address">
<LI><STRONG>Titel:</STRONG><br/>Text
<div class="gmap" address="Stationsstraat 23 8780 Oostrozebeke"></div></LI>
</ul>
<ul class="address">
<LI><STRONG>Titel:</STRONG>Text
<div class="gmap" address="Eredekestraat 56 2000 Antwerpen"></div></LI></UL>

这是我的 Javascript(带有 jQ​​uery):

     $(document).ready(function(){
var coll_gmap = $(".gmap");
if ( coll_gmap.length != 0 )
{
//initiate map
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}

//loop all addressen + insert into map
coll_gmap.each(function(index)
{
map = new google.maps.Map(coll_gmap[0], myOptions);
if (geocoder) {
geocoder.geocode( { 'address': $(this).attr("address")}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}//end if status
}); //end if geocoder.geocode
} //end if geocoder

}) //end coll_gmap each

}//end if coll_gmap length
}); //end onload


var geocoder, map;

最佳答案

我知道那是什么了。

我必须在

上设置宽度和高度
<div> =>(becomes)=>
<div style="width:500px;height:150px"></div>

我猜很容易忘记:(

关于javascript - Google map - 不显示但以 HTML 形式加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3236025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com