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