【发布时间】:2015-01-11 01:49:10
【问题描述】:
我只想显示一个默认信息窗口,内容为The 123456789。
所以我正在使用来自谷歌的地图example,并更改信息窗口内容。就这么简单。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"><meta charset="utf-8">
<title>Info windows</title>
<style>html, body, #map-canvas {height: 100%;margin: 0px;padding: 0px}</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {zoom: 4,center: myLatlng};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var infowindow = new google.maps.InfoWindow({
content: 'The 123456789'
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Uluru (Ayers Rock)'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head><body><div id="map-canvas"></div></body></html>
我在 Firefox 和 Chrome 中都得到了这个(预计 The 123456789)。只有在 IE 中我才有想要的结果。文本的其余部分被换行,并且在 chrome 中滚动条也是可见的。
现在,根据文档,应该扩展 InfoWindow 以适合我的文本,如果内容比我正在测试的内容长一点,它会这样做。这是谷歌地图样式问题吗?如何在没有自定义 InfoWindows 且没有 hackish css 的情况下简单地显示该文本?
编辑
再次测试了居住代码。信息窗口第一次显示有问题时,接下来会按应有的方式显示。
【问题讨论】:
-
您发布的代码适用于我的 Chrome。
-
@geocodezip 我第一次单击它时几乎显示为问题中的图像,随后的单击显示信息窗口应该如此。
-
这不是我在 Chrome 中看到的。你用的是什么浏览器?
-
截图使用的是firefox。在 chrome 中,我还在关闭按钮的左侧看到一个小的垂直滚动条