0
我想創建一個數組,將本地數據庫中的值推入到Titanium中的註釋中。註釋不響應我的數據庫的值。我想我在某個地方犯了一個學校男孩的錯誤,但我一直在盲目盯着自己。誰能幫我? 非常感謝! 乾杯。從數據庫註釋到Ti.map Appcelerator
功能的LocalDB(){
var db = Ti.Database.install('/my_db/annotations.sqlite', 'Annos');
var row = db.execute('select title, latitude, longitude, type from annotations ');
places = [];
while (row.isValidRow()){
var annotation = Titanium.Map.createAnnotation({
latitude:row.fieldByName('latitude'),
longitude:row.fieldByName('longitude'),
title:row.fieldByName('title'),
subtitle:row.fieldByName('type'),
animate:true,
pincolor: Titanium.Map.ANNOTATION_GREEN
});
places.push(annotation);
mapview.addAnnotation(annotation);
row.next();
}
mapview.annotations = places;
db.close();
}
var mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
height: '100%',
animate:true,
regionFit:true,
userLocation:true,
});
localdb();
win.add(mapview);
感謝隊友,大加讚賞。我通過添加mapview.annotations = places來解決它;到while循環中並刪除mapview.annotations = places;從功能完全。另外一些好的做法是添加一個row.close();函數結束之前,我被告知... :) – user2431848