@polar/plugin-draw
Version:
Draw plugin for POLAR that adds draw interactions to the map, allowing users to place various shapes and texts.
20 lines (18 loc) • 746 B
text/typescript
import { PolarActionContext } from '@polar/lib-custom-types'
import { Style } from 'ol/style'
import { Color } from 'ol/color'
import { ColorLike } from 'ol/colorlike'
import { DrawGetters, DrawState } from '../../types'
export default function (
{ commit }: PolarActionContext<DrawState, DrawGetters>,
featureStyle: Style
): void {
let strokeColor: Color | ColorLike
if (featureStyle && 'getImage' in featureStyle && featureStyle.getImage()) {
// @ts-expect-error | For some reason getStroke is not defined on the type but is callable.
strokeColor = featureStyle.getImage().getStroke().getColor()
} else {
strokeColor = featureStyle.getStroke()?.getColor() || 'black'
}
commit('setSelectedStrokeColor', strokeColor)
}