Google マップで Web ページを書いていますが、問題が発生しました。
非表示の div を含む InfoWindow があり、infoWindow のボタンをクリックしたときにそれを表示したいと考えています。しかし、問題は、非表示の div を表示すると、infoWindow のサイズが新しいコンテンツに自動的に適応しないことです。
この問題を解決するためのアドバイスをお願いします。どうもありがとう :-)
これが私のjsです:
function redraw() {
var cmt = $("#bodyContent");
cmt.show();
}
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var contentString = '<div id="content">'+
'<h2 id="firstHeading" class="firstHeading">Uluru</h2>'+
'<input type="button" value="Test" onclick="redraw()" />' +
'<div id="bodyContent" class="test">'+
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335 km (208 mi) '+
'south west of the nearest large town, Alice Springs; 450 km '+
'(280 mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p>'+
'</div>'+
'</div>';
infowindow = new google.maps.InfoWindow({
maxWidth: 300,
content: contentString
});
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);
});