From ee1b038714e701053dab6276c4a114e679c73e81 Mon Sep 17 00:00:00 2001 From: jkonieczny Date: Tue, 17 Dec 2019 09:06:19 +0100 Subject: [PATCH] add example to regularshape --- examples/regularshape.html | 4 +++- examples/regularshape.js | 27 ++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/examples/regularshape.html b/examples/regularshape.html index 1e3430a20a..990a9ec148 100644 --- a/examples/regularshape.html +++ b/examples/regularshape.html @@ -5,7 +5,9 @@ shortdesc: Example of some Regular Shape styles. docs: > This example shows how several regular shapes or symbols (representing `x`, `cross`, `star`, - `triangle` and `square`) can be created. + `triangle`, `square` and `stacked`) can be created. + + Style `stacked` represents possility to stack multiple shapes with offset tags: "vector, symbol, regularshape, style, square, cross, star, triangle, x" ---
diff --git a/examples/regularshape.js b/examples/regularshape.js index 6d26f9d3e3..4431efcd25 100644 --- a/examples/regularshape.js +++ b/examples/regularshape.js @@ -59,18 +59,39 @@ const styles = { radius2: 0, angle: Math.PI / 4 }) - }) + }), + 'stacked': [ + new Style({ + image: new RegularShape({ + fill: fill, + stroke: stroke, + points: 4, + radius: 5, + angle: Math.PI / 4, + offset: [0, 10] + }) + }), + new Style({ + image: new RegularShape({ + fill: fill, + stroke: stroke, + points: 4, + radius: 10, + angle: Math.PI / 4 + }) + }) + ] }; -const styleKeys = ['x', 'cross', 'star', 'triangle', 'square']; +const styleKeys = ['x', 'cross', 'star', 'triangle', 'square', 'stacked']; const count = 250; const features = new Array(count); const e = 4500000; for (let i = 0; i < count; ++i) { const coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e]; features[i] = new Feature(new Point(coordinates)); - features[i].setStyle(styles[styleKeys[Math.floor(Math.random() * 5)]]); + features[i].setStyle(styles[styleKeys[Math.floor(Math.random() * 6)]]); } const source = new VectorSource({