【发布时间】:2017-06-15 23:42:51
【问题描述】:
有没有办法像这样在 openlayer 3 中添加 kml 向量,但 kml 来自字符串变量?
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'https://openlayers.org/en/v4.2.0/examples/data/kml/2012-02-10.kml',
format: new ol.format.KML()
})
});
我试过这段代码,但它不起作用。
var kmlString = result;
var features = new ol.format.KML().readFeatures(kmlString);
var KMLvectorSource = new ol.source.Vector({
features: features
});
var KMLvector = new ol.layer.Vector({ source: KMLvectorSource });
//KMLvector.addFeatures(features);
map.addLayer(KMLvector);
提前致谢。
【问题讨论】:
标签: kml openlayers-3