admin管理员组文章数量:1387447
I have a google map in my website and for some reason when the page initially load there is a scroll bar for the info window but after clicking on other marker and ing back to the initially marker that was showing the info window, there is no scroll bar.
Here is a screenshot when the page loads:
After I click on the other markers with the "H" icon and e back to the building icon, the scroll bar is gone:
Here is my HTML/CSS/JQuery code:
<!DOCTYPE html>
<html>
<head>
<title>Map Location</title>
<script type="text/javascript" src=".11.0.min.js"></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
var infowindow = null;
var firstOne = null;
$(document).ready(function () {
initialize();
});
function initialize() {
var centerMap = new google.maps.LatLng(41.04356, -73.784445);
var myOptions = {
zoom: 12,
center: centerMap,
scaleControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, sites);
infowindow = new google.maps.InfoWindow({
content: "loading...", maxWidth: 350
});
infowindow.setContent(firstOne.html);
infowindow.open(map, firstOne);
//var bikeLayer = new google.maps.BicyclingLayer();
//bikeLayer.setMap(map);
}
var sites = [
['Administrative Office', 41.0237, -73.701239, 1, '<span class=ttl><b> Administrative Office</b></span><br><br><span class=sbj>0 Westchester Avenue<br>Purchase, NY 10577<br><img src="theImages/phone.png" width="12" height="12" /> 914.963.0700</span>'],
['Purchase Office', 41.005615, -73.69566551, 2, '<span class=ttl><b>Purchase Office</b></span><br><br><span class=sbj>3 Westchester Avenue<br>Purchase, NY 10577<br><img src="theImages/phone.png" width="12" height="12" /> 914.533.4570</span>'],
['Rye Office', 40.9756737, -73.65614, 3, '<span class=ttl><b>Rye Office</b></span><br><br><span class=sbj>45 Road<br>Rye, NY 10580<br><img src="theImages/phone.png" width="12" height="12" /> 914.845.8822</span>'],
['Scarsdale Office', 40.973478, -73.8433, 4, '<span class=ttl><b>Scarsdale Office</b></span><br><br><span class=sbj>6 White Plains Road, Suite 270<br>Scarsdale, NY 10583<br><img src="theImages/phone.png" width="12" height="12" /> 914.213.7670</span>'],
['White Plains Office', 41.04579, -73.7464, 5, '<span class=ttl><b>White Plains Office</b></span><br><br><span class=sbj>5 Westchester Avenue (GPS Enter: West Harrison)<br>White Plains, NY 10604<br><img src="theImages/phone.png" width="12" height="12" /> 914.672.0776</span>'],
['White Plains Office', 41.0563, -73.75618, 6, '<span class=ttl><b>White Plains Office</b></span><br><br><span class=sbj>5 Davfgs Avenue<br>White Plains, NY 10605<br><img src="theImages/phone.png" width="12" height="12" /> 914.541.2450</span>'],
['Yonkers Office', 40.9442, -73.8554, 6, '<span class=ttl><b>Yonkers Office</b></span><br><br><span class=sbj>5 Hill Blvd<br>Yonkers, NY 10710<br><img src="theImages/phone.png" width="12" height="12" /> 914.545.8022</span>']
];
function setMarkers(map, markers) {
for (var i = 0; i < markers.length; i++) {
var sites = markers[i];
var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
title: sites[0],
zIndex: sites[3],
html: sites[4]
});
var contentString = "Some content";
google.maps.event.addListener(marker, "click", function () {
//alert(this.html);
infowindow.setContent(this.html);
infowindow.open(map, this);
});
if(!firstOne) {
firstOne = marker;
marker.setIcon('theImages/hq.png');
}
else {
marker.setIcon('theImages/hicon.png');
}
}
}
</script>
<style>
.ttl {
font-family: Arial, Verdana;
font-size: 15px;
color: #049600;
text-align: left;
}
.sbj {
font-family: Tahoma, Arial, Verdana;
font-size: 12px;
font-weight: bold;
text-align: left;
}
</style>
</head>
<body>
<div id="map_canvas" style="width: 1050px; height: 395px; line-height: normal ! important"></div>
</body>
</html>
When the page loads, there is no scroll bar. Once the page fully loads, the scroll bar shows up. How do I fix the scroll bar issue?
I have a google map in my website and for some reason when the page initially load there is a scroll bar for the info window but after clicking on other marker and ing back to the initially marker that was showing the info window, there is no scroll bar.
Here is a screenshot when the page loads:
After I click on the other markers with the "H" icon and e back to the building icon, the scroll bar is gone:
Here is my HTML/CSS/JQuery code:
<!DOCTYPE html>
<html>
<head>
<title>Map Location</title>
<script type="text/javascript" src="http://code.jquery./jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://maps.google./maps/api/js?sensor=false"></script>
<script type="text/javascript">
var infowindow = null;
var firstOne = null;
$(document).ready(function () {
initialize();
});
function initialize() {
var centerMap = new google.maps.LatLng(41.04356, -73.784445);
var myOptions = {
zoom: 12,
center: centerMap,
scaleControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, sites);
infowindow = new google.maps.InfoWindow({
content: "loading...", maxWidth: 350
});
infowindow.setContent(firstOne.html);
infowindow.open(map, firstOne);
//var bikeLayer = new google.maps.BicyclingLayer();
//bikeLayer.setMap(map);
}
var sites = [
['Administrative Office', 41.0237, -73.701239, 1, '<span class=ttl><b> Administrative Office</b></span><br><br><span class=sbj>0 Westchester Avenue<br>Purchase, NY 10577<br><img src="theImages/phone.png" width="12" height="12" /> 914.963.0700</span>'],
['Purchase Office', 41.005615, -73.69566551, 2, '<span class=ttl><b>Purchase Office</b></span><br><br><span class=sbj>3 Westchester Avenue<br>Purchase, NY 10577<br><img src="theImages/phone.png" width="12" height="12" /> 914.533.4570</span>'],
['Rye Office', 40.9756737, -73.65614, 3, '<span class=ttl><b>Rye Office</b></span><br><br><span class=sbj>45 Road<br>Rye, NY 10580<br><img src="theImages/phone.png" width="12" height="12" /> 914.845.8822</span>'],
['Scarsdale Office', 40.973478, -73.8433, 4, '<span class=ttl><b>Scarsdale Office</b></span><br><br><span class=sbj>6 White Plains Road, Suite 270<br>Scarsdale, NY 10583<br><img src="theImages/phone.png" width="12" height="12" /> 914.213.7670</span>'],
['White Plains Office', 41.04579, -73.7464, 5, '<span class=ttl><b>White Plains Office</b></span><br><br><span class=sbj>5 Westchester Avenue (GPS Enter: West Harrison)<br>White Plains, NY 10604<br><img src="theImages/phone.png" width="12" height="12" /> 914.672.0776</span>'],
['White Plains Office', 41.0563, -73.75618, 6, '<span class=ttl><b>White Plains Office</b></span><br><br><span class=sbj>5 Davfgs Avenue<br>White Plains, NY 10605<br><img src="theImages/phone.png" width="12" height="12" /> 914.541.2450</span>'],
['Yonkers Office', 40.9442, -73.8554, 6, '<span class=ttl><b>Yonkers Office</b></span><br><br><span class=sbj>5 Hill Blvd<br>Yonkers, NY 10710<br><img src="theImages/phone.png" width="12" height="12" /> 914.545.8022</span>']
];
function setMarkers(map, markers) {
for (var i = 0; i < markers.length; i++) {
var sites = markers[i];
var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
title: sites[0],
zIndex: sites[3],
html: sites[4]
});
var contentString = "Some content";
google.maps.event.addListener(marker, "click", function () {
//alert(this.html);
infowindow.setContent(this.html);
infowindow.open(map, this);
});
if(!firstOne) {
firstOne = marker;
marker.setIcon('theImages/hq.png');
}
else {
marker.setIcon('theImages/hicon.png');
}
}
}
</script>
<style>
.ttl {
font-family: Arial, Verdana;
font-size: 15px;
color: #049600;
text-align: left;
}
.sbj {
font-family: Tahoma, Arial, Verdana;
font-size: 12px;
font-weight: bold;
text-align: left;
}
</style>
</head>
<body>
<div id="map_canvas" style="width: 1050px; height: 395px; line-height: normal ! important"></div>
</body>
</html>
When the page loads, there is no scroll bar. Once the page fully loads, the scroll bar shows up. How do I fix the scroll bar issue?
Share Improve this question asked Mar 14, 2014 at 15:21 Si8Si8 9,23522 gold badges119 silver badges223 bronze badges 1- Very similar question here: stackoverflow./questions/1554893/… – Simon E. Commented Aug 15, 2014 at 1:05
2 Answers
Reset to default 3try this:
#map_canvas > div > div:nth-child(1) > div > div:nth-child(3) > div:nth-child(3) > div > div.gm-style-iw {
overflow: visible !important;
}
Since it looks like you're headed down the route of including a lot of information in your info windows, you might benefit more from pursuing the route of building your own custom info windows. They have a great example up at http://gmaps-samples-v3.googlecode./svn/trunk/infowindow_custom/infowindow-custom.html . I noticed you have jquery on your page as well, you might even benefit from looking at this post on how to integrate jQuery UI using Google's "InfoBox" extension - http://thewebstorebyg.wordpress./2012/10/24/google-maps-api-v3-tabs-inside-the-infowindow-using-infobox/
本文标签: javascriptWhy Google Map infowindow has a scrollbarStack Overflow
版权声明:本文标题:javascript - Why Google Map infowindow has a scrollbar - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744551665a2612218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论