再会,
我正在尝试在我的谷歌地图上添加标记,但并非所有标记都显示。仅显示第一个地址标记。请看下面的代码:
//Search Button Event Handler
function getAccounts() {
//Search where City contains data
var Search = SearchText.value;
//alert("You have inserted: " + Search + " as a city");
if (Search != "") {
retrieveMultiple("AccountSet", "substringof('" + Search + "',Address1_City)", SearchCompleted, null);
}
//Retrieve all Accounts
else {
retrieveMultiple("AccountSet", null, SearchCompleted, null);
}
}
//Callback - Search Success
function SearchCompleted(data, textStatus, XmlHttpRequest) {
if (data && data.length > 0) {
for (var i=0; i < data.length; i++) {
var result = data[i];
var address = (data[i].Address1_Line1 + ", " + data[i].Address1_City + ", " + data[i].Address1_StateOrProvince + ", " + data[i].Address1_Country);
showAddress(address);
alert(result.Address1_Line1 + ", " +result.Address1_City + ", " + result.Address1_StateOrProvince + ", " + result.Address1_Country);
}
}
else {
alert('No records!');
}
}
function showAddress(address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address}, function (result, status) {
if (status == google.maps.GeocoderStatus.OK) {
var myOptions = {
zoom: 3,
center: result[0].geometry.location,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
//map.setCenter(result[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: result[0].geometry.location
});
} else {
Alert("Geocode was not successful for the following reason: "+ Status); // address not found
}
});
}
// ]]>
我知道信息已正确检索,因为 alert() 显示了所有检索到的信息