0
다음은 내 jquery 코드입니다. 부분보기를 사용하여 모달 팝업에서 Google지도를 렌더링하고 있습니다.모달 팝업에서 렌더링되지 않는 Google지도
브라우저 창 크기를 조정하거나 브라우저를 검사 할 때지도가 렌더링되지 않습니다 (창 크기 조정시 같은 문제).
또한 위도 - 경도 설정에 따라 중앙에 표시되지 않을 때 렌더링됩니다.
숨겨진 필드에서 설정된 위도 - 경도에 따라지도를 동적으로 렌더링하려고합니다. 현재 위도 = 30.704648600 및 경도 = 76.717872600을 전달합니다.
내가 무엇을 놓치고 있는지 모른다. TIA.
jQuery를이 -
$(document).ready(function() {
var currLoc;
if ($('#Latitude').val().length > 0 && $('#Longitude').val().length > 0)
initialize($('#Latitude').val(), $('#Longitude').val());
});
function initialize(Latitude, Longitude) {
var latlng = new google.maps.LatLng(Latitude, Longitude);
var map = new google.maps.Map(document.getElementById('map_'), {
center: latlng,
zoom: 13
});
var marker = new google.maps.Marker({
map: map,
position: latlng,
draggable: false,
//anchorPoint: new google.maps.Point(0, -29)
});
map.setCenter(new google.maps.LatLng(Latitude, Longitude));
var infowindow = new google.maps.InfoWindow();
currLoc= $('#lastLocation').text();
google.maps.event.addListener(marker, 'click', function() {
var iwContent = '<div id="iw_container">' +
'<div class="iw_title"><b>Last Location</b> : <span class="lastLoc">' + GetAddress(Latitude, Longitude) + '<span></div></div>';
infowindow.setContent(iwContent);
infowindow.open(map, marker);
});
}
function GetAddress(Latitude, Longitude) {
var LastLatLong = [];
LastLatLong.push([Latitude, Longitude]);
var latlngArray_ = LastLatLong[0];
var latlngset_ = new google.maps.LatLng(latlngArray_[0], latlngArray_[1]);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': latlngset_ }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
//currLoc= results[0].formatted_address;
if ($('.lastLoc').length > 0) {
debugger;
$('.lastLoc').text(results[0].formatted_address);
}
}
}
});
}
아마 div가 크기가 없으면 (표시가 없음)지도를 초기화하고있을 것입니다. 팝업이 열리면 초기화하거나 팝업을 시작하고 페이지로드시 팝업이 열리고 초기화 직후 숨겨집니다. 이를 위해 처음에는 불투명도 0을 사용하고 디스플레이 없음으로 숨기면 1로 변경합니다. –