这应该非常简单......我正在尝试创建一个包含其他三个变量内容的标记属性totalContent
,以便更轻松地根据多个过滤器搜索标记。
目前的代码如下:
downloadUrl("genxml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var country = markers[i].getAttribute("country");
var skills = markers[i].getAttribute("skills");
var interests = markers[i].getAttribute("interests");
var languages = markers[i].getAttribute("languages");
var totalContent = skills + " "+interests+" "+languages+ " ";
//window.alert(totalContent); --this works, it contains all the content--
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("long")));
var html = "<b>" + name + "</b> <br/>" + country + "<br/><b>Skills:</b>" + skills + "<br/><b>Interests:</b>" + interests + "<br/><b>Languages:</b>" + languages;
var marker = new google.maps.Marker({
map: map,
position: point,
skills: skills,
interests: interests,
languages: languages,
totalContent: totalContent // is this proper?
});
marker.skills = skills;
marker.interests = interests;
marker.languages = languages;
marker.totalContent = totalContent; //the top three works, but this doesn't?
gmarkers.push(marker);
}
});
当我尝试在脚本中的任何其他位置甚至在Chrome控制台中调用gmarkers [i] [totalContent]时,totalContent显示为未定义。我该如何解决这个问题?
由于
答案 0 :(得分:0)
我得到的数据产生gmarkers [i] .totalContent而不是gmarkers [i] [totalContent]。可能对别人有帮助。