Adding a notion of baseZoomLevel.

This commit is contained in:
Eric van der Vlist 2022-10-15 17:43:49 +02:00
parent 3a852ee19c
commit 22f1e9c8c6
2 changed files with 7 additions and 1 deletions

View File

@ -37,6 +37,8 @@ const Map: react.FC<MapProperties> = (props: MapProperties) => {
setZoom(zoom * zoomFactor); setZoom(zoom * zoomFactor);
}; };
const [baseZoomLevel, setBaseZoomLevel] = useState(10);
console.log(`Rendering Map, zoom:${zoom}, shift:${JSON.stringify(shift)}`); console.log(`Rendering Map, zoom:${zoom}, shift:${JSON.stringify(shift)}`);
return ( return (
@ -86,6 +88,8 @@ const Map: react.FC<MapProperties> = (props: MapProperties) => {
tileSize={256} tileSize={256}
key='tiled-layers' key='tiled-layers'
numberOfZoomLevels={5} numberOfZoomLevels={5}
baseZoomLevel={baseZoomLevel}
setBaseZoomLevel={setBaseZoomLevel}
/> />
<circle key='circle' cx='50' cy='50' r='50' />, <circle key='circle' cx='50' cy='50' r='50' />,
</> </>

View File

@ -13,6 +13,8 @@ interface TiledLayerConductorProperties {
zoom: number; zoom: number;
tileSize: number; tileSize: number;
numberOfZoomLevels?: number; numberOfZoomLevels?: number;
baseZoomLevel: number;
setBaseZoomLevel: (baseZoomLevel: number) => void;
} }
const TiledLayerConductor: react.FC<TiledLayerConductorProperties> = ( const TiledLayerConductor: react.FC<TiledLayerConductorProperties> = (
@ -37,7 +39,7 @@ const TiledLayerConductor: react.FC<TiledLayerConductorProperties> = (
const getTiledLayer = (i: number, isActive: boolean) => { const getTiledLayer = (i: number, isActive: boolean) => {
return ( return (
<TiledLayer <TiledLayer
key={`layer${i}`} key={`layer${i + props.baseZoomLevel}`}
height={props.height * 2 ** i} height={props.height * 2 ** i}
width={props.width * 2 ** i} width={props.width * 2 ** i}
shift={{ x: props.shift.x * 2 ** i, y: props.shift.y * 2 ** i }} shift={{ x: props.shift.x * 2 ** i, y: props.shift.y * 2 ** i }}