Add setStyle and getStyle to ol.Feature
As with vector layers and feature overlays, feature style can be set by calling setStyle. Calling getStyle returns what was passed to setStyle. Internally, we call getStyleFunction.
This commit is contained in:
@@ -18,19 +18,17 @@ var iconFeature = new ol.Feature({
|
||||
rainfall: 500
|
||||
});
|
||||
|
||||
var styleArray = [new ol.style.Style({
|
||||
var iconStyle = new ol.style.Style({
|
||||
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
|
||||
anchor: [0.5, 46],
|
||||
anchorXUnits: 'fraction',
|
||||
anchorYUnits: 'pixels',
|
||||
src: 'data/icon.png'
|
||||
}))
|
||||
})];
|
||||
|
||||
iconFeature.setStyleFunction(function(resolution) {
|
||||
return styleArray;
|
||||
});
|
||||
|
||||
iconFeature.setStyle(iconStyle);
|
||||
|
||||
var vectorSource = new ol.source.Vector({
|
||||
features: [iconFeature]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user