Openlayers 3 中可以与 feature.getStyle() 函数一起使用的函数有哪些?
What are the functions that can use with feature.getStyle() function in Openlayers 3?
我使用了以下代码来读取 KML 文件。如何获取从 kml 文件中提取的样式。我是否正确使用了 getStyle() 函数?
var parser = new ol.format.KML({extractStyles: true});
var testfeat=parser.readFeatures(kmlAsString,{featureProjection:'EPSG:3857' });
for(i=0;i<testfeat.length;i++)
{
console.log(testfeat[i].getStyle()); // What are the functions that use with getStyle()?
}
OpenLayers 的 ol.format.KML
读取 KML 文件中的样式定义并将它们存储在内部。将样式设置为功能时,格式对象使用样式函数来执行此操作,即 ol.FeatureStyleFunction
,请参阅:http://openlayers.org/en/latest/apidoc/ol.html#.FeatureStyleFunction
它在这里这样做,使用特征 setStyle
方法:https://github.com/openlayers/ol3/blob/v3.20.0/src/ol/format/kml.js#L1852
I 样式函数不能 return 像普通 ol.style.Style
对象那样的属性。它依靠地图分辨率来动态计算可以更改的属性。
总结:您无法访问使用 ol.format.KML
.
从 KML 文件中读出的样式定义
我使用了以下代码来读取 KML 文件。如何获取从 kml 文件中提取的样式。我是否正确使用了 getStyle() 函数?
var parser = new ol.format.KML({extractStyles: true});
var testfeat=parser.readFeatures(kmlAsString,{featureProjection:'EPSG:3857' });
for(i=0;i<testfeat.length;i++)
{
console.log(testfeat[i].getStyle()); // What are the functions that use with getStyle()?
}
OpenLayers 的 ol.format.KML
读取 KML 文件中的样式定义并将它们存储在内部。将样式设置为功能时,格式对象使用样式函数来执行此操作,即 ol.FeatureStyleFunction
,请参阅:http://openlayers.org/en/latest/apidoc/ol.html#.FeatureStyleFunction
它在这里这样做,使用特征 setStyle
方法:https://github.com/openlayers/ol3/blob/v3.20.0/src/ol/format/kml.js#L1852
I 样式函数不能 return 像普通 ol.style.Style
对象那样的属性。它依靠地图分辨率来动态计算可以更改的属性。
总结:您无法访问使用 ol.format.KML
.