我在'刷新'我的Google地圖後遇到問題,我無法單獨放置標記(單擊)。但在刷新我的地圖(初始化之前)之前,我可以通過單擊來放置標記。我可以知道代碼有什麼問題嗎?刷新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);
}
嗨科林,但我已經把變種地圖;作爲一個全球變量。 – 2010-11-25 01:08:30