Skip to content

Commit ca06a12

Browse files
committed
Dev | Examples | Leaflet Map: Adding zoom buttons to the colorMap example
1 parent e8a8c73 commit ca06a12

File tree

1 file changed

+9
-0
lines changed
  • packages/dev/src/examples/maps/leaflet/leaflet-map-colorMap

1 file changed

+9
-0
lines changed

packages/dev/src/examples/maps/leaflet/leaflet-map-colorMap/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export const component = (props: ExampleViewerDurationProps): React.ReactNode =>
3333
},
3434
})
3535

36+
const onZoomIn = (): void => { mapRef.current?.component?.zoomIn(1) }
37+
const onZoomOut = (): void => { mapRef.current?.component?.zoomOut(1) }
38+
const onFit = (): void => { mapRef.current?.component?.fitView() }
39+
3640
const pointId = (d: MapPointDataRecord): string => d.name
3741
const pointLatitude = (d: MapPointDataRecord): number => d.latitude
3842
const pointLongitude = (d: MapPointDataRecord): number => d.longitude
@@ -92,5 +96,10 @@ export const component = (props: ExampleViewerDurationProps): React.ReactNode =>
9296
},
9397
}}
9498
/>
99+
<div style={{ position: 'absolute', top: 32, right: 12, display: 'flex', flexDirection: 'column', gap: 8 }}>
100+
<button onClick={onZoomIn}>Zoom In</button>
101+
<button onClick={onZoomOut}>Zoom Out</button>
102+
<button onClick={onFit}>Fit View</button>
103+
</div>
95104
</>)
96105
}

0 commit comments

Comments
 (0)