POI in OpenLayer 3

一个人想着一个人 提交于 2019-12-12 03:27:00

问题


If load points from KML file to vetor layer

var layerPOI = new ol.layer.Vector({
  source: new ol.source.KML({
    projection: projection,
    url: 'data/KML/mydata.kml'
  })
})

How can I do a complete listing of all loaded points (POIs) and loaded properties (from data/KML/mydata.kml)? I think, for example, into the table - in map view (display layer) I can is already

Thank you very much for answer


回答1:


ol.source.KML has a method getFeatures() which gives you all features in your KML. Then you can use getProperties() or get() on the feature to read the properties.




回答2:


(Partial) solution:

allPOIs = layerPOI.getSource().getFeatures();
// or if define a source separatly
// allPOIs = sourcePOI.getFeatures(); 
onePOI = allPOIs[0]; // first element in Array
propertiesOfOnePOI = onePOI.getKeys();

propertiesOfOnePOI.forEach(function (elementName, elementIndex){
    console.log( "element index: " + elementIndex + " | element name: " + elementName + " | element value: " + onePOI.get(elementName) );
}); 

But the element GEOMTERY returns Object. I try to getting additional information about point yet but I can not - Also more tags from KML file - For example, point style - how to determine the displayed icon?

Please still help ;)



来源:https://stackoverflow.com/questions/28346229/poi-in-openlayer-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!