1

With ol 4.4.2 kml style with drag and drop is very difficult and I can't set it by the layer style. I can style it through the feature, but when I do, it's the style of the select interaction that does not work anymore. The extractStyle: false does not work anymore. Is there a bug ? How can I do it ?

dragAndDropInteraction.on('addfeatures', function(e) {
    var vectorSource = new ol.source.Vector({
        opacity: 1,
        features: new ol.Collection(),
        format: new ol.format.KML({
          extractStyles: false, defaultStyle: AnnotImportStyle 
        }),
        visible: true
    });
    var features = e.features;

    //features.forEach (function(s){s.setStyle(AnnotImportStyle)}); it works but put the style of select out
    vectorSource.addFeatures(features);
    var file_name = e.file.name;
    var name = file_name.substr(0, file_name.lastIndexOf('.'));
    var vector = new ol.layer.Vector({
        title: name,
        source: vectorSource,
        style: AnnotImportStyle,
        visible: true,
    });
    map.addLayer(vector);
    map.getView().fit(vectorSource.getExtent());
});
ericire
  • 409
  • 6
  • 22
  • 1
    Styles appear to be set on features despite `extractStyle: false` Here's a another case https://stackoverflow.com/questions/53017491/heatmap-in-openlayers-using-an-xml-kml-formatted-string-styling-is-incorrect To remove them use `features.forEach(function(feature){feature.setStye(undefined)});` then your layer style will be used. – Mike Mar 06 '19 at 22:04
  • Hello yes I had thought of that, but I did not know how to cancel a style. it works flawlessly. thank you. – ericire Mar 07 '19 at 06:17

0 Answers0