Select Openlayers 3,从所选功能获取id

Select Openlayers 3,从所选功能获取id,select,openlayers-3,Select,Openlayers 3,我有这一层 $.getJSON(“/g_estados/GetPrediosJson”),空,函数(数据) { var format=new ol.format.WKT(); var feature=新数组(); 对于(i=0,len=data.length;i e、 target.getFeatures().getLength()+ '所选特征(上次选择的操作'+>e.selected.length+ '和取消选择'+e.deselected.length+'>features'); //do

我有这一层

$.getJSON(“/g_estados/GetPrediosJson”),空,函数(数据)
{
var format=new ol.format.WKT();
var feature=新数组();
对于(i=0,len=data.length;i
有些人选择这样的选项:

featuresSelect=新建ol.Collection()

select=null;//引用当前选定的交互
//选择“单点单击”上的交互操作
var selectSingleClick=newol.interaction.Select({features:>featuresSelect});
//选择“单击”上的交互操作
var selectClick=new ol.interaction.Select({
条件:ol.events.condition.click,
功能:功能选择
});
//选择“pointermove”上的交互操作
var selectPointerMove=新建ol.interaction.Select({
条件:ol.events.condition.pointerMove,
功能:功能选择
});
var selectAltClick=新建ol.interaction.Select({
条件:函数(mapBrowserEvent)
{
返回ol.events.condition.click(mapBrowserEvent)&&
ol.events.condition.altKeyOnly(mapBrowserEvent);
}
});
var changeInteraction=函数()
{
如果(选择!==null)
{
map.removeInteraction(选择);
}
var值='singleclick';
如果(值=='singleclick')
{
select=selectSingleClick;
}否则如果(值=='单击')
{
选择=选择单击;
}否则
{
select=null;
}
如果(选择!==null)
{
map.addInteraction(选择);
select.on('select',函数(e)
{
document.getElementById('status')。innerHTML=''>
e、 target.getFeatures().getLength()+
'所选特征(上次选择的操作'+>e.selected.length+
'和取消选择'+e.deselected.length+'>features');
//document.getElementById('id01').style.display=>'block';
//console.log(e.selected);
//log(e.target.getFeatures()[0]);
console.log(特性选择);
//console.log(特性选择[0]);
var features2=新数组;
功能2=功能选择;
console.log(特性2)
对于(i=0,len=featureselect.getLength();ii++)
{
console.log(特性选择[i]);
}
//{
所以,在我选择了一个特性之后,我想知道这个id,以便根据这个id调用其他函数,但我已经在这个问题上纠缠了好几个小时,openlayers的示例和文档还没有得到足够的支持

注意:我不寻求jquery(我不知道)或其他框架,只寻求纯javascript、html、css


我使用的是最新版本的openlayers,谢谢您的帮助。

好的,我已经更改了按像素选择功能的方法,所以现在就解决了。我已经完成了,现在可以工作了,但无法使用select获取功能,所以我将其更改为按像素选择功能,完成了,谢谢
       $.getJSON("/g_estados/GetPrediosJson", null, function (data)
       {

           var format = new ol.format.WKT();

           var feature = new Array();

           for (i = 0, len = data.length; i < len; i++)
           {
               var fea = format.readFeature(data[i].wkt
                   , {
                       dataProjection: 'EPSG:3857',
                       featureProjection: 'EPSG:3857',
                       id: data[i].clave_catastral_g
                   }
           );
               //fea.attributes
               if (i < 10) {
                   console.log(fea)
               }
               feature.push(fea);
           }


           c_estados = new ol.layer.Vector({
               name: 'estados',
               source: new ol.source.Vector({
                   features: feature
               }),
               style: new ol.style.Style({
                   fill: new ol.style.Fill({
                       color: 'rgba(255, 255, 255, 0.2)'
                   }),
                   stroke: new ol.style.Stroke({
                       color: '#ffcc33',
                       width: 2
                   }),
                   image: new ol.style.Circle({
                       radius: 7,
                       fill: new ol.style.Fill({
                           color: '#ffcc33'
                       })
                   })

               })
           });
       select = null;  // ref to currently selected interaction
       // select interaction working on "singleclick"
       var selectSingleClick = new ol.interaction.Select({ features: >featuresSelect });

      // select interaction working on "click"
       var selectClick = new ol.interaction.Select({
           condition: ol.events.condition.click,
           features: featuresSelect
       });

       // select interaction working on "pointermove"
       var selectPointerMove = new ol.interaction.Select({
           condition: ol.events.condition.pointerMove,
           features: featuresSelect
       });

       var selectAltClick = new ol.interaction.Select({
           condition: function (mapBrowserEvent)
           {
               return ol.events.condition.click(mapBrowserEvent) &&
                   ol.events.condition.altKeyOnly(mapBrowserEvent);
           }
       });

       var changeInteraction = function ()
       {
           if (select !== null)
           {
               map.removeInteraction(select);
           }
           var value = 'singleclick';
           if (value == 'singleclick')
           {
               select = selectSingleClick;
           } else if (value == 'click')
           {
               select = selectClick;
           } else
           {
               select = null;
           }
           if (select !== null)
           {
               map.addInteraction(select);
               select.on('select', function (e)
               {

                   document.getElementById('status').innerHTML = '&nbsp;' >
                       e.target.getFeatures().getLength() +
                       ' selected features (last operation selected ' + >e.selected.length +
                       ' and deselected ' + e.deselected.length + ' >features)';
                   //document.getElementById('id01').style.display = >'block';
                   //console.log(e.selected);
                   //console.log(e.target.getFeatures()[0]);
                   console.log(featuresSelect);
                   //console.log(featuresSelect[0]);


                   var features2 = new Array;
                   feature2 = featuresSelect;

                   console.log(features2)

                   for (i = 0, len = featuresSelect.getLength() ; i < len; >i++)
                   {
                       console.log(featuresSelect[i]);
                   }
                   //{