AssociativeArray
是CesiumJS中的一个类,代表一个关联数组,可以根据字符串作为key去存储和访问一个元素。
var associativeArray = new Cesium.AssociativeArray();
var associativeArray = new Cesium.AssociativeArray();
associativeArray.set('key1', element1);
associativeArray.set('key2', element2);
var element1 = associativeArray.get('key1');
var hasKey1 = associativeArray.contains('key1');
associativeArray.remove('key1');
var keys = associativeArray.keys;
var elements = associativeArray.values;
var associativeArray = new Cesium.AssociativeArray();
// 添加元素
associativeArray.set('a', 1);
associativeArray.set('b', 2);
associativeArray.set('c', 3);
// 获取元素
var valueA = associativeArray.get('a'); // 1
// 检查是否有元素
var hasKeyA = associativeArray.contains('a'); // true
var hasKeyD = associativeArray.contains('d'); // false
// 删除元素
associativeArray.remove('a');
// 获取所有元素的key
var keys = associativeArray.keys; // ['b', 'c']
// 获取所有元素
var elements = associativeArray.values; // [2, 3]