1
我目前正試圖在Mapbox地圖上反應性地顯示標記。我的方法是觀察一個集合,同時創建一個GeoJSON對象。但是,該特定對象中的更改不反映在地圖上。流星:帶映射箱的反應性標記
var featureArray = [];
CollectionName.find({}).observe({
added: function(item) {
featureArray.push({
type: "Feature",
geometry: {
type: "Point",
coordinates: [+item.location.coordinates[0], +item.location.coordinates[1]]
},
properties: {
_id: item._id,
}
});
},
changedAt: function(newDocument, oldDocument, atIndex) {
//..
},
removed: function(oldDocument, atIndex) {
//..
}
});
var CollectionGeoJSON = {
'type': 'FeatureCollection',
'features': testmarkers
};
var markers = L.mapbox.featureLayer().setGeoJSON(CollectionGeoJSON);
// add cluster markers and add them to map
我的想法是在這裏手動添加/刪除/修改客戶端上的標誌物(如更改同步到服務器反正),但也沒有成功因爲我不知道如何使用做Mapbox API。
任何提示,非常感謝。
謝謝你的幫助!我相應地改變了我的集合模式,並且做到了這一點。我已經在onRendered回調中使用了template.autorun;轉換似乎是問題。 – leandermelms