單擊標記並出現InfoWindow時,如果內容的長度比InfoWindow的默認高度(90px)長,則高度不會調整。獲取Google Maps v3以調整InfoWindow的高度
- 我正在使用文本,沒有圖像。
- 我試過maxWidth。
- 我檢查過繼承的CSS。
- 我已經將我的內容封裝在div 中,並將我的CSS應用到該高度,包括 。
- 我甚至試圖強制 InfoWindow使用jQuery 使用InfoWindow的 上的domready事件來調整大小。
我只剩下幾根毛髮。這裏是我的JS:
var geocoder;
var map;
var marker;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(41.8801,-87.6272);
var myOptions = {
zoom: 13,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function codeAddress(infotext,address) {
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var image = '/path-to/mapMarker.png';
var infowindow = new google.maps.InfoWindow({ content: infotext, maxWidth: 200 });
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
icon: image
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
});
}
function checkZipcode(reqZip) {
if (/[0-9]{5}/.test(reqZip)) {
$.ajax({
url: 'data.aspx?zip=' + reqZip,
dataType: 'json',
success: function(results) {
$.each(results.products.product, function() {
var display = "<span id='bubble-marker'><strong>"+this.name+"</strong><br>"+
this.address+"<br>"+
this.city+", "+this.state+" "+this.zip+"<br>"+
this.phone+"</span>";
var address = this.address+","+
this.city+","+
this.state+","+
this.zip;
codeAddress(display,address);
});
},
error: function() { $('#information-bar').text('fail'); }
});
} else { $('#information-bar').text('Zip codes are five digit numbers.'); }
}
$('#check-zip').click(function() { $('#information-bar').text(''); checkZipcode($('#requested-zipcode').val()); });
initialize();
InfoText和地址來自XML文件的AJAX查詢。數據不是問題,因爲它始終是正確的。在檢索並格式化數據後調用codeAddress()。
HTML文件中:
<div id="google_map"> <div id="map_canvas" style="width:279px; height:178px"></div> </div>
CSS我的信息窗口的內容(沒有其他的CSS適用於地圖):
#bubble-marker{ font-size:11px; line-height:15px; }
您是否曾經找到過解決方案?我有完全相同的問題... – Jeremy 2011-05-17 19:31:38
我無法得到這個固定的,爲了我的頭髮和理智,最終只是重做了我正在嘗試做的事情。想知道是否有解決方案... – Jeremy 2011-05-17 22:24:04