Show an example of changing the color with setfill

This commit is contained in:
Duck
2022-06-16 07:56:03 -07:00
parent 4ef584b410
commit c182bbf66b
3 changed files with 16 additions and 0 deletions

View File

@@ -129,3 +129,14 @@ const map = new Map({
zoom: 2,
}),
});
const colors = ['blue', 'green', 'yellow', 'aqua', 'red'];
let currentColor = 0;
document.getElementById('color-changer').addEventListener('click', function () {
styles.square
.getImage()
.setFill(new Fill({color: colors[currentColor % colors.length]}));
vectorLayer.changed();
currentColor++;
});