Skip to content

IconSymbolizer and DPR #209

@ycouble

Description

@ycouble

I'm using IconSymbolizer on point features. I followed the sprite example to set icons with the IconSymbolizer. However, DPR doesn't seem to be well handled : on my iPhone (high DPR) it looks huge, on my desktop (dpr~2) it looks ok (tuned it for it), and on my collegue desktop (DPR = 1) it is tiny.

Playing a bit with the code, I saw that adding the following bits solves the issue for me.

    const draw = (ctx: CanvasRenderingContext2D) => {
      ctx.globalAlpha = 1;
      ctx.drawImage(
        this.sheet.canvas,
        loc.x,
        loc.y,
        loc.w,
        loc.h,
        -loc.w / 2 / this.dpr,
        -loc.h / 2 / this.dpr,
        loc.w / 2 / this.dpr, // THIS BIT
        loc.h / 2 / this.dpr, // THIS BIT
      );
    };

I'm certainly not an expert on dpr and drawing on screen, so... does that make any sense ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions