The current way to add layer from KML file is:
var urlToKml = someUrl;
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
url: urlToKml,
format: new ol.format.KML()
}),
visible: true
});
map.addLayer(vector);
I'd like to load my source from a string
(ie: where urlToKml = "<kml xmlns='http://www.opengis.net/kml/2.2' xmlns:gx='http://www.google.com/kml/ext/2.2' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd'><Placemark><description>hrt</description><Style><IconStyle><Icon><href>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==</href><gx:w>5</gx:w><gx:h>5</gx:h></Icon><hotSpot x='2.5' y='2.5' xunits='pixels' yunits='pixels'/></IconStyle></Style><Point><coordinates>2.335711304736855,49.10454920376088</coordinates></Point></Placemark></kml>";
)
Is it possible and how?