Appcelerator 循环中的注解有问题

Having issues with annotations in a loop in Appcelerator

所以这是我第一次使用 Appcelerator 的地图模块,我可以使用一些建议来尝试在我的地图上为我确定的每个位置显示注释。 dbArray 是从另一个模块传入的,我已经验证数组中有数据,但是我不确定如何在循环中处理它。任何人都可以提出任何建议来帮助指导我吗?

var buildSecUI = function(dbArray){    //dbArray from data.js read function
console.log("---buildSecUI is activated---");
console.log(dbArray);

var secWin = Ti.UI.createWindow({
    layout: "vertical",
    backgroundColor: "#ffffff"
});

//building the map
var Map = require('ti.map');

var mapView = Map.createView({
    mapType: Map.NORMAL_TYPE,
    region: {latitude:25.2867, longitude:51.5333,
        latitudeDelta:0.05, longitudeDelta:0.05},
    animate:true,
    regionFit:true,
    userLocation:true
});

//array for annotations (pins for maps)
var annotations = [];

for ( var i = 0 ; i < dbArray.length; i++ ) {
// this section will create annotations and add them on the mapView
    var pin  = Map.createAnnotation({
        latitude: this.dbArray[i].lat,
        longitude: this.dbArray[i].lng,
        title: this.dbArray[i].name,
        animate:true,
        pincolor:Map.ANNOTATION_PURPLE
    });

    annotations[i] = pin;
    //annotations.push(pin);

mapView.addAnnotation(annotations[i]);  // adds annotations   
}   //for loop closure

secWin.add(mapView);
navWin.openWindow(secWin); }; //closure for buildSecUI

在您的循环中,您指的是 "this.dbArray[i]",它应该只是 "dbArray[i]"。 "this.dbArray" 可能未定义。