如何在创建时设置ol.Feature
id。
到目前为止的示例和结果:
// attempt 1
var fea = new ol.Feature({ id : 123 });
console.log(fea);
// attempt 2
var fea = new ol.Feature();
fea.id = 123;
console.log(fea);
// attempt 3
var fea = new ol.Feature();
fea.id = "123";
console.log(fea);
结果:
尝试1:
尝试2:
尝试3:
最佳答案
创建后使用feature.setId(id)
http://openlayers.org/en/v3.8.2/apidoc/ol.Feature.html#setId
关于javascript - 创建时设置功能 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32092432/