I am currently attempting to create a Heatmap in OpenLayers using a KML string. From this string, I read the features, add them into a VectorSource, then add the source to the H
Thanks to @Mike, the solution was to set the feature styles to undefined. This ensures the pins do not override the styles that are being applied from the Heatmap layer.
So the new code looks as follows:
var kmlFeatures = new ol.format.KML().readFeatures(data["xml"],{
dataProjection : 'EPSG:4326',
featureProjection : 'EPSG:3857'
});
var source = new ol.source.Vector({
features: kmlFeatures,
format: new ol.format.KML({
extractStyles: false
})
})
for (var i = 0; i < source.getFeatures().length; i++) {
var feature = source.getFeatures()[i];
var name = feature.get('name');
feature.set('weight', parseFloat(name));
feature.set('type', "OTHER");
feature.setStyle(undefined);
}
var vector = new ol.layer.Heatmap({
source: source,
blur: parseInt(15, 10),
radius: parseInt(5, 10)
});
map.getMap().addLayer(vector);
The solution feels a bit hacky, but it works.