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:
Tim Schaub
2014-02-12 16:49:53 -07:00
parent 477c369f6c
commit f4585331f2
5 changed files with 172 additions and 20 deletions

View File

@@ -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]
});