You need to define a style that will be used by your select interaction. This is mine for example:
selectedStyle = {
LineString: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 8
})
}),
Polygon: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 4
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
Point: new ol.style.Style({
image: new ol.style.RegularShape({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.5)'
}),
stroke: new ol.style.Stroke({
color: 'red',
width: 1
}),
points: 4,
radius: 8,
angle: Math.PI / 4
})
})
}
In order to apply the correct style we need a style function to check the features:
var selectedStyleFunction = function (feature, resolution) {
var featureStyleFunction = feature.getStyleFunction();
if (featureStyleFunction) {
return featureStyleFunction.call(feature, resolution);
} else {
var type = feature.getGeometry().getType();
return selectedStyle[type];
}
}
Once defined, this can be added to the Select interaction object like this:
session.interactions.select = new ol.interaction.Select({
style: selectedStyleFunction,
multi: true
});
I've tried to simplify this from my own code but hopefully haven't made a mistake(!)
Best Answer
You could check that by instanceof operator comparing your geometry to ol.geom[type] where type is string representation of your type (see below). This example should do it:
Types are e.g.: Polygon, LineString, Point, MultiLineString, MultiPolygon, Circle etc., complete list of geometry types is here.