From 30311f0b653502694b0b48a3d43c4e4f54cca27b Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 7 Nov 2013 15:04:24 +0100 Subject: [PATCH] Add ol.style --- src/ol/style.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/ol/style.js diff --git a/src/ol/style.js b/src/ol/style.js new file mode 100644 index 0000000000..d683df5c76 --- /dev/null +++ b/src/ol/style.js @@ -0,0 +1,101 @@ +goog.provide('ol.style.DefaultStyleFunction'); +goog.provide('ol.style.Style'); +goog.provide('ol.style.StyleFunction'); + +goog.require('goog.functions'); + + +/** + * @typedef {{color: string, + * opacity: number}} + */ +ol.style.Fill; + + +/** + * @typedef {{anchor: Array., + * image: (HTMLCanvasElement|HTMLVideoElement|Image), + * rotation: number, + * subtractViewRotation: boolean}} + */ +ol.style.Image; + + +/** + * @typedef {{color: string, + * width: number}} + */ +ol.style.Stroke; + + +/** + * @typedef {{fill: ol.style.Fill, + * image: ol.style.Image, + * stroke: ol.style.Stroke, + * zIndex: number}} + */ +ol.style.Style; + + +/** + * @typedef {function(ol.Feature): ol.style.Style} + */ +ol.style.StyleFunction; + + +/** + * @const + * @type {ol.style.Fill} + */ +ol.style.DEFAULT_FILL_STYLE = { + color: 'red', + opacity: 0.1 +}; + + +/** + * @const + * @type {ol.style.Image} + */ +ol.style.DEFAULT_IMAGE_STYLE = { + anchor: [0, 0], + image: null, // FIXME + rotation: 0.0, + subtractViewRotation: false +}; + + +/** + * @const + * @type {ol.style.Stroke} + */ +ol.style.DEFAULT_STROKE_STYLE = { + color: 'red', + width: 3 +}; + + +/** + * @const + * @type {number} + */ +ol.style.DEFAULT_Z_INDEX = 0; + + +/** + * @const + * @type {ol.style.Style} + */ +ol.style.DEFAULT_STYLE = { + fill: ol.style.DEFAULT_FILL_STYLE, + image: ol.style.DEFAULT_IMAGE_STYLE, + stroke: ol.style.DEFAULT_STROKE_STYLE, + zIndex: ol.style.DEFAULT_Z_INDEX +}; + + +/** + * @param {ol.Feature} feature Feature. + * @return {ol.style.Style} Style. + */ +ol.style.DefaultStyleFunction = goog.functions.constant(ol.style.DEFAULT_STYLE);