私のページの 1 つの jQuery プラグインで Google マップを呼び出していますが、タブ div にマップ全体をロードしていません。解決策はAjaxだと思います。私はGoogleで言うように試しましたが、うまくいかないようです。
よろしくお願いします...
function initializeMap(address) {
var mapVar = {
latitude: "",
longitude: "",
myLatlng: ""
};
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
mapVar.latitude = results[0].geometry.location.lat();
mapVar.longitude = results[0].geometry.location.lng();
mapVar.myLatlng = new google.maps.LatLng(mapVar.latitude, mapVar.longitude);
//-----define map options---//
var mapOptions = {
center: mapVar.myLatlng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: mapVar.myLatlng,
map: map,
title: address
});
} //end if
});
}
html
<div id="map_canvas" style="width:61.4em; height:400px;"></div>
CSS
#map_canvas {
width:61.4em;
height: 100%;
}