@@ -39,6 +39,18 @@ const CLASS_FILTER = [
3939const DOM_FILTER_FUNC = node => ! CLASS_FILTER . includes ( node . className ) ;
4040const OUT_OF_SCREEN_POSITION = - 9999 ;
4141
42+ /**
43+ * Linearly remaps the export scale range [1..4] to a reduced legend scale [1..3].
44+ * Prevents the legend from scaling as aggressively as the exported image.
45+ * @param linearScale - scale factor (e.g., 1, 2, 3, 4, 5)
46+ * @returns remapped scale factor
47+ */
48+ function calculateLogarithmicLegendScale ( scale : number ) : number {
49+ const max = 4 ;
50+ const t = ( scale - 1 ) / ( max - 1 ) ;
51+ return 1 + t * 2 ;
52+ }
53+
4254PlotContainerFactory . deps = [ MapContainerFactory , MapsLayoutFactory ] ;
4355
4456// Remove mapbox logo in exported map, because it contains non-ascii characters
@@ -57,6 +69,11 @@ const StyledPlotContainer = styled.div`
5769 position: absolute;
5870 top: ${ OUT_OF_SCREEN_POSITION } px;
5971 left: ${ OUT_OF_SCREEN_POSITION } px;
72+
73+ /* Apply logarithmic zoom to legend panel */
74+ .map-control-panel {
75+ zoom: var(--legend-scale, 1) !important;
76+ }
6077` ;
6178
6279interface StyledMapContainerProps {
@@ -312,7 +329,12 @@ export default function PlotContainerFactory(
312329 ) ;
313330
314331 return (
315- < StyledPlotContainer className = "export-map-instance" >
332+ < StyledPlotContainer
333+ className = "export-map-instance"
334+ style = { {
335+ '--legend-scale' : calculateLogarithmicLegendScale ( scale )
336+ } as React . CSSProperties }
337+ >
316338 < StyledMapContainer ref = { plottingAreaRef } width = { size . width } height = { size . height } >
317339 < MapViewStateContextProvider mapState = { newMapState } >
318340 { mapContainers }
0 commit comments