Javascript openlayer 3.5从点获取特征id

Javascript openlayer 3.5从点获取特征id,javascript,openlayers-3,Javascript,Openlayers 3,我还在学习openlayers,我有一个问题。我需要为我的脚本的id点,如果这是点击。有了这个id(作为变量的函数),我想做一些编码 借助一些示例,我成功地在我的网站上获得了一个表 map.on('singleclick',函数(evt){ document.getElementById('nodelist').innerHTML=“正在加载…请稍候…”; var view=map.getView(); var viewsolution=view.getResolution(); var sou

我还在学习openlayers,我有一个问题。我需要为我的脚本的id点,如果这是点击。有了这个id(作为变量的函数),我想做一些编码

借助一些示例,我成功地在我的网站上获得了一个表

map.on('singleclick',函数(evt){
document.getElementById('nodelist').innerHTML=“正在加载…请稍候…”;
var view=map.getView();
var viewsolution=view.getResolution();
var source=untiled.get('visible')?untiled.getSource():tiled.getSource();
var url=source.getFeatureInfoURL(
evt.coordinate、viewResolution、view.getProjection(),
{'INFO_FORMAT':'text/html','FEATURE_COUNT':50});
如果(url){
document.getElementById('nodelist')。innerHTML='';
}
});
但是我想要的不是显示表并从表中获取点的id


谁能给我一些提示吗

如果要访问功能ID,则不能在GetFeatureInfo请求中使用“text/html”格式。相反,您必须使用“application/vnd.ogc.gml”或“application/json”格式。只有当服务器允许CORS请求,或者服务器与应用程序位于同一来源时,这才有效。然后,您将不得不在AJAX请求中使用它,而不是在IFRAME中使用来自
source.getGetFeatureInfoUrl()
的url。使用
ol.format.WMSGetFeatureInfo
ol.format.GeoJSON
解析响应,对于解析后的功能,您只需使用
ol.Feature#getId()

即可获得id,具体取决于此。显示更多代码,特别是如何将它们添加到源代码中。海报使用的是WMS层,因此客户端无法使用这些功能。
map.on('singleclick', function(evt) {
    document.getElementById('nodelist').innerHTML = "Loading... please wait...";
    var view = map.getView();
    var viewResolution = view.getResolution();
    var source = untiled.get('visible') ? untiled.getSource() : tiled.getSource();
    var url = source.getGetFeatureInfoUrl(
      evt.coordinate, viewResolution, view.getProjection(),
      {'INFO_FORMAT': 'text/html', 'FEATURE_COUNT': 50});
    if (url) {
      document.getElementById('nodelist').innerHTML = '<iframe seamless src="' + url + '"></iframe>';
    }
  });