-2
我試圖建立一個值的數組,我可以用它來添加標記到谷歌地圖,但不斷收到此錯誤。下面的代碼,任何關於我哪裏出錯的建議(對此很新鮮......)非常感謝。無法設置屬性1的未定義 - javascript/google maps api
感謝 保羅
var result2 = sforce.connection.queryAll("select Name,Lat__c,Long__c, Status__c from Site__c where Lat__c != null");
var records = result2.getArray('records');
var store_locations = new Array();
var Approved_store_locations = new Array();
var Rejected_store_locations = new Array();
var a=0,b=0,c=0;
for (var j=0; j< records.length; j++)
{
var record = records[j];
if (record.Status__c == "IB Approved")
{
Approved_store_locations[a][1] = [[new google.maps.LatLng(record.Lat__c, record.Long__c)],[record.Name]];
alert(Approved_store_locations[a][1]);
a++
} else if (record.Status__c == "Site Dead")
{
Rejected_store_locations[b][1] = [[new google.maps.LatLng(record.Lat__c, record.Long__c)],[record.Name]];
b++
} else
{
store_locations[c][1] = [[new google.maps.LatLng(record.Lat__c, record.Long__c)],[record.Name]];
c++
}
}
map = new google.maps.Map(document.getElementById("map"), myOptions);
for (i=0; i < store_locations.length; i++)
{
marker2 = new google.maps.Marker(
{
position: store_locations[i][0],
title: store_locations[0][i],
map: map
});
iconfile = 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png';
marker2.setIcon(iconfile);
}
for (i=0; i < Approved_store_locations.length; i++)
{
marker3 = new google.maps.Marker(
{
position: Approved_store_locations[i][0],
title: store_locations[0][i],
map: map
});
iconfile = 'http://maps.google.com/mapfiles/ms/icons/green-dot.png';
marker3.setIcon(iconfile);
}
for (i=0; i < Rejected_store_locations.length; i++)
{
marker = new google.maps.Marker(
{
position: Rejected_store_locations[i][0],
title: store_locations[0][i],
map: map
});
iconfile = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png';
marker3.setIcon(iconfile);
}
在代碼中這個錯誤出現在哪裏?請提供更多信息。 store_locations [c] [1] = [[new google.maps.LatLng(record.Lat__c,record.Long__c)],[record.Name]在最後一個循環 – slawekwin 2012-03-07 11:23:07
中的範圍marker3對象]。 – user1254490 2012-03-07 13:01:20