-
Notifications
You must be signed in to change notification settings - Fork 2k
Feat/add more kepler map export resultions resolutions #3351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5dda6b6
d626f74
56f2b3a
16aa6d2
62ff976
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,9 +6,8 @@ | |||||
| import ImagePreview from '../common/image-preview'; | ||||||
| import {SetExportImageSettingUpdaterAction} from '@kepler.gl/actions'; | ||||||
|
|
||||||
| import {EXPORT_IMG_RATIO_OPTIONS, EXPORT_IMG_RESOLUTION_OPTIONS} from '@kepler.gl/constants'; | ||||||
| import {ExportImage} from '@kepler.gl/types'; | ||||||
| import {StyledModalContent, SelectionButton, CheckMark} from '../common/styled-components'; | ||||||
|
Check failure on line 10 in src/components/src/modals/export-image-modal.tsx
|
||||||
|
||||||
| import {StyledModalContent, SelectionButton, CheckMark} from '../common/styled-components'; | |
| import {StyledModalContent} from '../common/styled-components'; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,18 @@ const CLASS_FILTER = [ | |||||||||
| const DOM_FILTER_FUNC = node => !CLASS_FILTER.includes(node.className); | ||||||||||
| const OUT_OF_SCREEN_POSITION = -9999; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Linearly remaps the export scale range [1..5] to a reduced legend scale [1..3]. | ||||||||||
| * Prevents the legend from scaling as aggressively as the exported image. | ||||||||||
| * @param scale - scale factor (e.g., 1, 2, 3, 4, 5) | ||||||||||
| * @returns remapped scale factor | ||||||||||
| */ | ||||||||||
| function remapLegendScale(scale: number): number { | ||||||||||
| const max = 5; | ||||||||||
| const t = (scale - 1) / (max - 1); | ||||||||||
|
||||||||||
| const t = (scale - 1) / (max - 1); | |
| // Clamp scale to the expected input range to ensure the output stays within [1..3] | |
| const clampedScale = Math.min(Math.max(scale, 1), max); | |
| const t = (clampedScale - 1) / (max - 1); |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the CSS zoom property for .map-control-panel is non-standard and not supported consistently across browsers (notably Firefox). For more reliable export rendering, prefer a standards-based approach like transform: scale(...) with an appropriate transform-origin, or apply scaling via layout calculations instead of zoom.
| zoom: var(--legend-scale, 1) !important; | |
| transform-origin: top left; | |
| transform: scale(var(--legend-scale, 1)) !important; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,25 +4,13 @@ | |
| import {Blob, URL, atob, Uint8Array, ArrayBuffer, document} from 'global/window'; | ||
| import get from 'lodash/get'; | ||
|
|
||
| import { | ||
| EXPORT_IMG_RESOLUTION_OPTIONS, | ||
| EXPORT_IMG_RATIO_OPTIONS, | ||
| RESOLUTIONS, | ||
| EXPORT_IMG_RATIOS, | ||
| FourByThreeRatioOption, | ||
| OneXResolutionOption | ||
| } from '@kepler.gl/constants'; | ||
| import {ExportImage} from '@kepler.gl/types'; | ||
| import {generateHashId} from '@kepler.gl/common-utils'; | ||
| import domtoimage from './dom-to-image'; | ||
| import {set} from './utils'; | ||
| import {exportMapToHTML} from './export-map-html'; | ||
| import {getApplicationConfig} from './application-config'; | ||
|
|
||
| const defaultResolution = OneXResolutionOption; | ||
|
|
||
| const defaultRatio = FourByThreeRatioOption; | ||
|
|
||
| export function isMSEdge(window: Window): boolean { | ||
| // @ts-ignore msSaveOrOpenBlob was a proprietary addition to the Navigator object, added by Microsoft for Internet Explorer. | ||
| return Boolean(window.navigator && window.navigator.msSaveOrOpenBlob); | ||
|
|
@@ -38,36 +26,11 @@ export function getScaleFromImageSize(imageW = 0, imageH = 0, mapW = 0, mapH = 0 | |
| return base / mapBase; | ||
| } | ||
|
|
||
| export function calculateExportImageSize({ | ||
| mapW, | ||
| mapH, | ||
| ratio, | ||
| resolution | ||
| }: { | ||
| mapW: number; | ||
| mapH: number; | ||
| ratio: keyof typeof EXPORT_IMG_RATIOS; | ||
| resolution: keyof typeof RESOLUTIONS; | ||
| }) { | ||
| if (mapW <= 0 || mapH <= 0) { | ||
| return null; | ||
| } | ||
|
|
||
| const ratioItem = EXPORT_IMG_RATIO_OPTIONS.find(op => op.id === ratio) || defaultRatio; | ||
|
|
||
| const resolutionItem = | ||
| EXPORT_IMG_RESOLUTION_OPTIONS.find(op => op.id === resolution) || defaultResolution; | ||
|
|
||
| const {width: scaledWidth, height: scaledHeight} = resolutionItem.getSize(mapW, mapH); | ||
|
|
||
| const {width: imageW, height: imageH} = ratioItem.getSize(scaledWidth, scaledHeight); | ||
|
|
||
| const {scale} = ratioItem.id === EXPORT_IMG_RATIOS.CUSTOM ? {scale: undefined} : resolutionItem; | ||
|
|
||
| export function calculateExportImageSize({}: {}) { | ||
| return { | ||
| scale, | ||
| imageW, | ||
| imageH | ||
| scale: 1, | ||
| imageW: 0, | ||
| imageH: 0 | ||
| }; | ||
|
Comment on lines
+29
to
34
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs now state
DEFAULT_EXPORT_IMAGEhas aresolutiondefault of'SIZE_1024_768', but the reducer default (DEFAULT_EXPORT_IMAGE) and the exportedExportImagetype in this PR no longer include aresolutionfield. Please align the documentation with the actual state shape (either document the new model, or restore theresolutionfield in code/types).