import * as React from 'react' ; import { Slider } from 'antd' ; import OlLayerBase from 'ol/layer/Base' ; import { SliderSingleProps } from 'antd/lib/slider' ; export interface BaseProps { /**
     * The layer to handle.
     */ layer : OlLayerBase ; } export type LayerTransparencySliderProps = BaseProps & SliderSingleProps ; class extends React . Component class LayerTransparencySlider extends React . Component < LayerTransparencySliderProps > { param transparency setLayerTransparency ( transparency ) { const { layer } = this . props ; let opacity = 1 - ( transparency / 100 ) ; opacity = Math . round ( ( opacity ) * 100 ) / 100 ; layer . setOpacity ( opacity ) ; } return getLayerTransparency ( ) { const { layer } = this . props ; const opacity = layer . getOpacity ( ) ; let transparency = ( 1 - opacity ) * 100 ; transparency = Math . round ( transparency ) ; return transparency ; } /**
     * The render function.
     */ render ( ) { const { layer , ... passThroughProps } = this . props ; return ( < Slider tipFormatter = { value => `${ value }%` } defaultValue = { this . getLayerTransparency ( ) } onChange = { ( value ) => { this . setLayerTransparency ( value as number ) ; } } { ... passThroughProps } />); } } export default LayerTransparencySlider ;