Skip to content
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

PB-1278: Fix Icon with offset (pin) changes positon #1174

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/api/print.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ class GeoAdminCustomizer extends BaseCustomizer {
)
: 0
// don't ask why it works, but that's the best I could do.

symbolizer.graphicYOffset = symbolizer.graphicYOffset
? (symbolizer.graphicYOffset = adjustWidth(-size[1], this.printResolution))
: 0
symbolizer.gaphicYOffset = Math.round(1000 * symbolizer.gaphicYOffset ?? 0) / 1000
}
if (size) {
symbolizer.graphicWidth = adjustWidth(size[0] * scale, this.printResolution)
Expand Down
6 changes: 4 additions & 2 deletions src/utils/styleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ export const highlightPointStyle = new Style({
// Change a width according to the change of DPI (from the old geoadmin)
// Originally introduced here https://github.com/geoadmin/mf-geoadmin3/pull/3280
export function adjustWidth(width, dpi) {
if (!width || isNaN(width) || width <= 0.0 || !dpi || isNaN(dpi) || dpi <= 0) {
if (!width || isNaN(width) || !dpi || isNaN(dpi) || dpi <= 0) {
ismailsunni marked this conversation as resolved.
Show resolved Hide resolved
return 0
}

if (width <= 0) {
return -adjustWidth(-width, dpi)
}
return Math.max((width * PRINT_DPI_COMPENSATION) / dpi, MIN_PRINT_SCALE_SIZE)
}
Loading