gpt4 book ai didi

javascript - 谷歌地图背景图片在浏览器中显示不正确

转载 作者:太空宇宙 更新时间:2023-11-04 09:34:11 24 4
gpt4 key购买 nike

我正在使用 JavaScript 在我的网页上实现 Google map 。我的问题是 map 带有 marker 但它的背景图像根本没有显示。屏幕截图如下。

enter image description here

这是我的代码:

<div id="dvMap" style="width:1000px; height:1000px;"></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>



<script>
var markers = [{"lat":"20.295728","lng":"85.844990"},{"title":"shilparamam","lat":"20.295728","lng":"85.844990","description":"Mumbai formerly Bombay, is the capital city of the Indian state of Maharashtra."}];
window.onload = function () {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
var infoWindow = new google.maps.InfoWindow();
var lat_lng = new Array();
var latlngbounds = new google.maps.LatLngBounds();
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
lat_lng.push(myLatlng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
latlngbounds.extend(marker.position);
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
}
</script>

这里我需要 Google map 的清晰背景图片。

最佳答案

为什么不使用简单的 iframe 而不是这么长的脚本?下面的链接为您提供了获取 iframe 代码的简单步骤,您只需使用 html div 将其嵌入到您的元素或网站中。 http://www.dummies.com/web-design-development/site-development/how-to-embed-a-google-map-with-iframe/

关于javascript - 谷歌地图背景图片在浏览器中显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40500481/

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