mmomtchev / rlayers

React Component Library for OpenLayers
ISC License
173 stars 36 forks source link

Can not set default map rotation in RMap #290

Open itsdapi opened 2 months ago

itsdapi commented 2 months ago

The view init is hard coded and can not pass the rotation property to the view.

    constructor(props: Readonly<RMapProps>) {
        super(props);
        this.target = React.createRef();
        this.ol = new Map({
            controls: props.noDefaultControls ? [] : undefined,
            interactions: props.noDefaultInteractions ? [] : undefined,
            view: new View({
                projection: props.projection,
                center: props.initial.center,
                zoom: props.initial.resolution === undefined ? props.initial.zoom : undefined,
                resolution: props.initial.resolution,
                extent: props.extent,
                minResolution: props.minResolution,
                maxResolution: props.maxResolution,
                constrainResolution: props.constrainResolution,
                minZoom: props.minZoom,
                maxZoom: props.maxZoom,
                enableRotation: props.enableRotation,
                constrainRotation: props.constrainRotation
            })
        });
        if (this.props.view) this.ol.on('moveend', this.updateView);
    }

Adding the rotation property to RView would be nice

mmomtchev commented 2 months ago

I will accept a PR