0
我有一個數組:訪問JavaScript數組對谷歌地圖地點標記
var = CITIES {
"Buenos Aires":
{latitude: -34.6084, longitude: -58.3732},
"Santiago":
{latitude: -33.4254, longitude: -70.5665},
"Gaborone":
{latitude: -24.6541, longitude: 25.9087},
...
};
我需要放置在2D谷歌地圖標記;我嘗試用這個功能來做到這一點:
/*
* void
* mark()
*
* Markes locations of study abroad programs all around the world map
*/
function mark()
{
// mark programs
for (var city in CITIES)
{
// plant cities on map
new google.maps.Marker({
icon: "http://google-maps-icons.googlecode.com/files/smallcity.png",
map: map,
position: new google.maps.LatLng(CITIES[city].latitude, CITIES[city].longitude),
title: 'CITIES[city]'
});
}
}
JS的控制檯是給我一個錯誤說:
missing variable name
[Break on this error] var = CITIES {\n
我知道錯誤與我訪問與城市參數城市做,但我如何解決這個問題並獲取必要的信息?
所以錯誤似乎消失了。但是,我需要做些什麼來使地標出現? – 2010-12-09 13:32:03