Skip to content
Snippets Groups Projects
MapProperties.ts 949 B
import Map from 'ol/Map';
import colormap from 'colormap';

export default class MapProperties{

    private map: Map;
    private projection: string;

    constructor(map:Map, projection: string){
        this.map = map;
        this.projection = projection;
    }

    public getTemperatureColorMap(): string[]{
        return colormap({colormap:'RdBu', nshades: 20, format: 'hex', alpha: 1});
    }

    public getTemperatureIcon(color: string): string{
        let icon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="%color%"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"   stroke="black"/></svg>';
        return icon.replace("%color%", color.replace("#", "%23"));
    }

    public getZoomLevel():number{
        return this.map.getView().getZoom();
    }

    public getProjection(): string{
        return this.projection;
    }

}