Google マップを Twitter ブートストラップ モーダルに表示しようとしています。ユーザーが最初にボタンをクリックするとShow map
、マップonclick()
関数を生成しているため、マップを正常に表示できますが、モーダルを閉じて再度開くと、マップが正しく表示されず、マップの 90% の部分が次のように灰色になります
マップがバインドされている div 全体を削除して再生成するこの回避策も試してみましたが、そのトリックはうまくいきません。問題を解決する方法を教えてください。
以下は、ショーマップのonclickイベントを呼び出している私のjs関数です
function mapp()
{
//google.maps.event.trigger(map, "resize");
//$("#map_google_canvas").empty();
$("#map_google_canvas").remove();
$("#crmap").append("<div id='map_google_canvas'></div>")
var myOptions = {
center: new google.maps.LatLng(54, -2),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_google_canvas"), myOptions);
var addressArray = new Array("London, United Kingdom", "London Road, Brentwood, United Kingdom", "Brentwood, United Kingdom");
var geocoder = new google.maps.Geocoder();
var markerBounds = new google.maps.LatLngBounds();
for (var i = 0; i < addressArray.length; i++) {
geocoder.geocode({
'address': addressArray[i]
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
markerBounds.extend(results[0].geometry.location);
map.fitBounds(markerBounds);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
親切に助けて、
ありがとう