import { useState, useEffect, useContext } from 'react'
import GlobalContext from '../../../../utils/GlobalContext';
import { MapContext } from '../MapContext';
export default function ImageLayer(props) {
    const { xyzImageOpts } = useContext(GlobalContext);
    const { viewer } = useContext(MapContext);

    useEffect(() => {
        if (viewer) {
            let l = new window.Cesium.UrlTemplateImageryProvider({
                ...xyzImageOpts
                // maximumLevel: 18,
                // url: xyzImageryUrl || 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
            });
            viewer.imageryLayers.addImageryProvider(l);
        }
    }, [viewer, xyzImageOpts])

    return null;
}