@polar/plugin-draw
Version:
Draw plugin for POLAR that adds draw interactions to the map, allowing users to place various shapes and texts.
16 lines (14 loc) • 619 B
text/typescript
import { PolarActionContext } from '@polar/lib-custom-types'
import { Style } from 'ol/style'
import { DrawGetters, DrawState } from '../../types'
export default function (
{ commit, getters }: PolarActionContext<DrawState, DrawGetters>,
featureStyle: Style
): void {
const featureText = featureStyle.getText()?.getText()
const font = featureStyle.getText()?.getFont() as string
// set selectedSize of feature to prevent unintentional size change
const fontSize = font.match(/\b\d+(?:.\d+)?/)
commit('setSelectedSize', getters.fontSizes.indexOf(Number(fontSize)))
commit('setTextInput', featureText)
}