javascript - 创建时设置功能 ID

标签 javascript openlayers-3

如何在创建时设置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:

attempt 1

尝试2:

enter image description here

尝试3:

enter image description here

最佳答案

关于javascript - 创建时设置功能 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32092432/

相关文章:

javascript - javascript中函数的替代方法

Javascript 数字格式

javascript - JQuery .click() 在特定嵌套 div 更改 css 上不起作用

php - 406 和 404 错误 - 仅 Firefox 有问题?

layer - openlayers 3 缩放到组合范围

javascript - 将 HTML 字符串传递给 JavaScript 函数

javascript - 缩放(中心) map 到 OpenLayers 3 中的标记

javascript - 开放层 3 : stylefunction is not called for unselected features after zoom/pan

javascript - OpenLayers 3 检索 View 的高度

javascript - 如何从geojson openlayers3获取图像源