0
添加KML是有任何方式在openlayer 3添加KML矢量这样但KML是从字符串变量的OpenLayers 3如何使用字符串变量
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);
在此先感谢
顺便说一句,我不使用来自的OpenLayers的KML。我有一个字符串变量,其中包含字符串它的投影在3857年。和我已经尝试过的代码,但它不工作有没有错误,但kml层不显示 – gray
是否有任何其他方式加载从kml数据库,而不是传递给字符串 – gray
您的问题是如何加载它来自字符串。更好地决定你真正想要什么,这样我们就不会浪费时间。 – pavlos