Google지도를 '새로 고침'한 후 문제가 생겼습니다. 직접 마커에 배치 할 수 없습니다 (클릭). 그러나지도를 새로 고치기 전에 (초기화로) 클릭하여 마커를 배치 할 수 있습니다. 코드에 어떤 문제가 있는지 알 수 있습니까? 내가 정확히, 당신이 refreshMap
함수를 호출 한 후지도가 작동하지 않는 것을 말하는 문제를 이해한다면Google지도를 새로 고침하면 마커를 추가 할 수 없습니다.
다음은
//Initialize the map
function initialize() {
var myLatlng = new google.maps.LatLng(2,110);
var myOptions = {
zoom: 3,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
infowindow = new google.maps.InfoWindow({
content: "loading..."
});
}
// Listen for click for markers
function marker()
{
google.maps.event.addListener(map, 'click', function(event) {
addMarker(event.latLng);
});
}
// Place markers in by click
function addMarker(location) {
marker = new google.maps.Marker({
position: location,
map: map,
title:"Specified Location",
icon: 'images/greenPoint.png'
});
markersArray.push(marker);
}
function refreshMap()
{
var myLatlng = new google.maps.LatLng(1.1,107);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
안녕 콜린,하지만 난 이미 VAR지도를 뒀다 ; 위에 글로벌 변수로. –