@versatiles/png-renderer 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +12 -8
  2. package/dist/index.d.ts +260 -69
  3. package/dist/index.js +16198 -12297
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -77,7 +77,9 @@ const map = new PNGMapRenderer({ style, fetch: cachedFetch });
77
77
 
78
78
  ### Labels in the style's own fonts
79
79
 
80
- A style only _names_ its fonts (`"text-font": ["noto_sans_regular"]`). Map each name to a font file (TTF, OTF, WOFF or WOFF2) with `fonts`; a name left unmapped falls back to a font installed on the machine.
80
+ With `labels: 'glyphs'` (or `'glyphs-text'`), labels are drawn as the style's own glyphs, the letter shapes MapLibre GL JS draws, and need no font files.
81
+
82
+ With `labels: 'text'`, labels are drawn in fonts: a style only _names_ its fonts (`"text-font": ["noto_sans_regular"]`). Map each name to a font file (TTF, OTF, WOFF or WOFF2) with `fonts`; a name left unmapped falls back to a font installed on the machine.
81
83
 
82
84
  ```typescript
83
85
  const png = await renderToPNG({
@@ -85,7 +87,7 @@ const png = await renderToPNG({
85
87
  lon: 13.4,
86
88
  lat: 52.5,
87
89
  zoom: 14,
88
- renderLabels: true,
90
+ labels: 'text',
89
91
  fonts: {
90
92
  noto_sans_regular: 'fonts/NotoSans-Regular.ttf',
91
93
  noto_sans_bold: 'fonts/NotoSans-Bold.ttf',
@@ -99,16 +101,18 @@ The VersaTiles styles use Noto Sans. One source is `npm install @fontsource/noto
99
101
 
100
102
  ### `renderToPNG(options): Promise<Uint8Array>`
101
103
 
102
- Takes every option of [`renderToSVG`](https://github.com/versatiles-org/versatiles-svg-renderer/blob/main/packages/svg-renderer/README.md#api) (`style`, `width`, `height`, `lon`, `lat`, `zoom`, `renderLabels`, `fetch`), plus:
104
+ Takes every option of [`renderToSVG`](https://github.com/versatiles-org/versatiles-svg-renderer/blob/main/packages/svg-renderer/README.md#api) (`style`, `width`, `height`, `lon`, `lat`, `zoom`, `labels`, `fetch` and more), plus:
103
105
 
104
- | Option | Type | Default | Description |
105
- | ------- | ------------------------ | ------- | ---------------------------------------------------------------------------------------------------- |
106
- | `scale` | `number` | `1` | Pixel density: the image is `width × scale` by `height × scale` pixels. Use `2` for sharp output. |
107
- | `fonts` | `Record<string, string>` | — | Font files for labels, by the `text-font` name the style uses: `{ noto_sans_regular: 'path.woff2' }` |
106
+ | Option | Type | Default | Description |
107
+ | ------- | ------------------------ | ------- | -------------------------------------------------------------------------------------------------------------------------- |
108
+ | `scale` | `number` | `1` | Pixel density: the image is `width × scale` by `height × scale` pixels. Use `2` for sharp output. |
109
+ | `fonts` | `Record<string, string>` | — | Font files for labels with `labels: 'text'`, by the `text-font` name the style uses: `{ noto_sans_regular: 'path.woff2' }` |
108
110
 
109
111
  The result is typed as a `Uint8Array` so the package does not require Node's type definitions; at runtime it is a `Buffer` and can be written with `fs.writeFile` as is.
110
112
 
111
- Label rendering has the same limitations as in SVG output: [see `renderLabels`](https://github.com/versatiles-org/versatiles-svg-renderer/blob/main/packages/svg-renderer/README.md#about-renderlabels).
113
+ Label rendering has the same limitations as in SVG output: [see "About labels"](https://github.com/versatiles-org/versatiles-svg-renderer/blob/main/packages/svg-renderer/README.md#about-labels). With `'glyphs'`, PNG and SVG show the same letter shapes; `'glyphs-text'` draws as `'glyphs'`, since a PNG has no text.
114
+
115
+ Which MapLibre GL JS features are covered, and which are not yet: [MapLibre GL JS Coverage](https://github.com/versatiles-org/versatiles-svg-renderer#maplibre-gl-js-coverage).
112
116
 
113
117
  ### `new PNGMapRenderer(options)`
114
118
 
package/dist/index.d.ts CHANGED
@@ -2708,6 +2708,9 @@ type Feature$1 = {
2708
2708
  readonly geometry?: Array<Array<Point2D$1>>;
2709
2709
  };
2710
2710
 
2711
+ /** Values of the style's global state, by name, as read by `global-state` expressions. */
2712
+ type GlobalState = Record<string, unknown>;
2713
+
2711
2714
  type Properties = Record<string, unknown>;
2712
2715
  type Patterns = Record<string, {
2713
2716
  min: string;
@@ -2750,44 +2753,26 @@ declare class Feature implements Feature$1 {
2750
2753
  doesOverlap(bbox: Bbox): boolean;
2751
2754
  }
2752
2755
 
2753
- /**
2754
- * The part of a `Response` the renderer uses. A real `Response` has all of it; the type
2755
- * is spelled out so that using this package needs neither the DOM nor Node's type
2756
- * definitions.
2757
- */
2758
- interface FetchResponse {
2759
- readonly ok: boolean;
2760
- readonly status: number;
2761
- readonly headers: {
2762
- get(name: string): string | null;
2763
- };
2764
- arrayBuffer(): Promise<ArrayBuffer>;
2765
- json(): Promise<unknown>;
2766
- }
2767
- /**
2768
- * Loads a URL, like `fetch`: the renderer loads tiles and sprites through it. It is called
2769
- * with the URL only, and should resolve to a `Response`.
2770
- */
2771
- type FetchFunction = (url: string) => Promise<FetchResponse>;
2772
-
2773
- interface SpriteEntry {
2774
- width: number;
2775
- height: number;
2776
- x: number;
2777
- y: number;
2778
- pixelRatio: number;
2779
- sdf: boolean;
2780
- sheetDataUri: string;
2781
- sheetWidth: number;
2782
- sheetHeight: number;
2783
- }
2784
- type SpriteAtlas = Map<string, SpriteEntry>;
2785
-
2786
2756
  interface ClipCircle {
2787
2757
  x: number;
2788
2758
  y: number;
2789
2759
  radius: number;
2790
2760
  }
2761
+ type Triangle = [[number, number], [number, number], [number, number]];
2762
+ /** A triangle of a raster tile's mesh on the globe, drawn with its own affine transform. */
2763
+ interface RasterTriangle {
2764
+ /** Corners of the triangle within the tile image, in tile units (0..1). */
2765
+ source: Triangle;
2766
+ /** The same corners on screen, in pixels. */
2767
+ target: Triangle;
2768
+ }
2769
+ /** Space around the map's center, as MapLibre's `padding`, in pixels. */
2770
+ interface Padding {
2771
+ top?: number;
2772
+ right?: number;
2773
+ bottom?: number;
2774
+ left?: number;
2775
+ }
2791
2776
 
2792
2777
  /**
2793
2778
  * A drawing surface the render pipeline paints a map onto. It only describes *how* to
@@ -2798,10 +2783,19 @@ interface ClipCircle {
2798
2783
  interface Renderer {
2799
2784
  readonly width: number;
2800
2785
  readonly height: number;
2801
- drawBackgroundFill(style: BackgroundStyle): void;
2802
- drawPolygons(id: string, features: [Feature, FillStyle][]): void;
2803
- drawLineStrings(id: string, features: [Feature, LineStyle][]): void;
2786
+ /**
2787
+ * These two may be asynchronous, like {@link Renderer.drawIcons}: a pattern is a sprite
2788
+ * image, which a raster backend has to decode first.
2789
+ */
2790
+ drawBackgroundFill(style: BackgroundStyle): void | Promise<void>;
2791
+ drawPolygons(id: string, features: [Feature, FillStyle][]): void | Promise<void>;
2792
+ /** May be asynchronous, as a line pattern is a sprite image (see `drawPolygons`). */
2793
+ drawLineStrings(id: string, features: [Feature, LineStyle][]): void | Promise<void>;
2804
2794
  drawCircles(id: string, features: [Feature, CircleStyle][]): void;
2795
+ /**
2796
+ * Draws text labels, and (below) icons. Each feature is a single point: the pipeline
2797
+ * has already placed the symbol, one per point, line or polygon.
2798
+ */
2805
2799
  drawLabels(id: string, features: [Feature, SymbolStyle][]): void;
2806
2800
  /**
2807
2801
  * These two may be asynchronous. Their images arrive as data URIs, which a raster
@@ -2819,13 +2813,65 @@ interface Renderer {
2819
2813
  */
2820
2814
  finish?(): void;
2821
2815
  }
2816
+ /**
2817
+ * How labels and icons are drawn: not at all, as `<text>`, as the style's glyphs traced
2818
+ * into outlines, or as those with invisible text over them.
2819
+ */
2820
+ type LabelMode = 'none' | 'text' | 'glyphs' | 'glyphs-text';
2821
+ /**
2822
+ * A glyph's outline, in pixels at 24 per em (`GLYPH_EM`), as closed rings (to be filled
2823
+ * even-odd): x from the middle of its advance, y from the middle of its line of text.
2824
+ */
2825
+ interface GlyphOutline {
2826
+ /** Identifies the outline, for renderers that define each once. */
2827
+ key: string;
2828
+ rings: [number, number][][];
2829
+ /** The glyph's advance, in ems. */
2830
+ advance: number;
2831
+ }
2832
+ /** A glyph of a label drawn as glyphs: its outline, its middle on screen, angle and scale. */
2833
+ interface PlacedGlyph {
2834
+ outline: GlyphOutline;
2835
+ /** Where the middle of the glyph's advance lies, in the middle of its line of text. */
2836
+ x: number;
2837
+ y: number;
2838
+ /** Clockwise, in degrees. */
2839
+ angle: number;
2840
+ /** From the outline's units (24 per em) to pixels: the text size / 24. */
2841
+ scale: number;
2842
+ }
2822
2843
  interface BackgroundStyle {
2823
2844
  color: Color;
2824
2845
  opacity: number;
2846
+ /** `background-pattern`: drawn instead of `color`. */
2847
+ pattern?: FillPattern;
2848
+ }
2849
+ /**
2850
+ * A sprite image repeated over an area (`fill-pattern`, `background-pattern`), at its
2851
+ * display size (`width / pixelRatio`) and anchored to the world, as in MapLibre.
2852
+ */
2853
+ interface FillPattern {
2854
+ /** The image's name in the sprite. */
2855
+ name: string;
2856
+ sprite: SpriteEntry;
2857
+ /**
2858
+ * A screen point where one copy of the image has its top-left corner: one aligned with
2859
+ * the world's origin, so the pattern moves with the map.
2860
+ */
2861
+ origin: [number, number];
2862
+ /** How far the pattern turns around `origin`, clockwise in degrees: with the map's bearing. */
2863
+ angle?: number;
2864
+ /**
2865
+ * How much larger than its display size the image is drawn (1 if not given): MapLibre
2866
+ * scales patterns with the map from the zoom level's integer part, as its tiles are.
2867
+ */
2868
+ scale?: number;
2825
2869
  }
2826
2870
  interface FillStyle {
2827
2871
  color: Color;
2828
2872
  opacity: number;
2873
+ /** `fill-pattern`: drawn instead of `color`. */
2874
+ pattern?: FillPattern;
2829
2875
  translate: [number, number];
2830
2876
  /**
2831
2877
  * fill-outline-color. When omitted the fill `color` is used (MapLibre's
@@ -2851,14 +2897,31 @@ interface LineStyle {
2851
2897
  opacity: number;
2852
2898
  translate: [number, number];
2853
2899
  width: number;
2900
+ /** `line-pattern`: drawn instead of `color` and `dasharray`. */
2901
+ pattern?: LinePattern;
2902
+ }
2903
+ /**
2904
+ * A sprite image repeated along a line (`line-pattern`), spanning its width, as in MapLibre
2905
+ * (see `line_pattern.ts`).
2906
+ */
2907
+ interface LinePattern {
2908
+ /** The image's name in the sprite. */
2909
+ name: string;
2910
+ sprite: SpriteEntry;
2911
+ /** How far one copy of the image reaches along the line, in pixels. */
2912
+ period: number;
2854
2913
  }
2855
2914
  interface CircleStyle {
2856
2915
  color: Color;
2916
+ /** Opacity of the fill only; the stroke has its own, as in MapLibre. */
2857
2917
  opacity: number;
2858
2918
  radius: number;
2859
2919
  translate: [number, number];
2860
2920
  strokeWidth: number;
2861
2921
  strokeColor: Color;
2922
+ strokeOpacity: number;
2923
+ /** `circle-blur`: the share of the outer radius over which the circle fades out. */
2924
+ blur?: number;
2862
2925
  }
2863
2926
  interface RasterStyle {
2864
2927
  opacity: number;
@@ -2869,7 +2932,41 @@ interface RasterStyle {
2869
2932
  contrast: number;
2870
2933
  resampling: 'linear' | 'nearest';
2871
2934
  }
2935
+ /** One character of a label along a line: its center, and its angle in degrees. */
2936
+ interface GlyphPlacement {
2937
+ text: string;
2938
+ x: number;
2939
+ y: number;
2940
+ angle: number;
2941
+ }
2872
2942
  interface SymbolStyle {
2943
+ /**
2944
+ * For a label along a line: where each of its characters goes. The label is drawn glyph
2945
+ * by glyph there, centered on each position, instead of at the feature's point.
2946
+ */
2947
+ path?: GlyphPlacement[];
2948
+ /**
2949
+ * For a label drawn as the style's glyphs: each glyph's outline, where it goes and how
2950
+ * large. Drawn instead of the text.
2951
+ */
2952
+ glyphs?: PlacedGlyph[];
2953
+ /** With `glyphs`: also the text, invisible, so the label stays selectable and searchable. */
2954
+ textOverlay?: boolean;
2955
+ /**
2956
+ * For a label of several lines: each line, and the point its alignment (`justify`)
2957
+ * refers to, vertically at the middle of the line. The anchor and offset are applied
2958
+ * already; `text` is all lines.
2959
+ */
2960
+ lines?: {
2961
+ text: string;
2962
+ x: number;
2963
+ y: number;
2964
+ width?: number;
2965
+ }[];
2966
+ /** How the `lines` align at their points (`text-justify`). */
2967
+ justify?: 'left' | 'center' | 'right';
2968
+ /** `text-letter-spacing`, in ems. */
2969
+ letterSpacing?: number;
2873
2970
  text: string;
2874
2971
  size: number;
2875
2972
  font: string[];
@@ -2892,6 +2989,11 @@ interface IconStyle {
2892
2989
  color: Color;
2893
2990
  haloColor: Color;
2894
2991
  haloWidth: number;
2992
+ /**
2993
+ * Fitted to its label (`icon-text-fit`): the box the icon spans, `[left, top, right,
2994
+ * bottom]` from its point, before `icon-size`; `anchor` and `offset` then do not apply.
2995
+ */
2996
+ fit?: [number, number, number, number];
2895
2997
  }
2896
2998
  interface RasterTile {
2897
2999
  x: number;
@@ -2904,38 +3006,96 @@ interface RasterTile {
2904
3006
  * triangles, each drawn with its own affine transform.
2905
3007
  */
2906
3008
  triangles?: RasterTriangle[];
3009
+ /**
3010
+ * An image on its own (an `image` source), with no neighbouring tiles to close seams
3011
+ * with: its triangles are drawn without the underlay that reaches beyond its border.
3012
+ */
3013
+ standalone?: boolean;
2907
3014
  }
2908
- type Triangle = [[number, number], [number, number], [number, number]];
2909
- interface RasterTriangle {
2910
- /** Corners of the triangle within the tile image, in tile units (0..1). */
2911
- source: Triangle;
2912
- /** The same corners on screen, in pixels. */
2913
- target: Triangle;
3015
+ /** An image of the style's sprite: where it is on its sprite sheet, and how it stretches. */
3016
+ interface SpriteEntry {
3017
+ width: number;
3018
+ height: number;
3019
+ x: number;
3020
+ y: number;
3021
+ pixelRatio: number;
3022
+ sdf: boolean;
3023
+ sheetDataUri: string;
3024
+ sheetWidth: number;
3025
+ sheetHeight: number;
3026
+ /** The columns of the image that stretch with `icon-text-fit`, as `[from, to]` pixels. */
3027
+ stretchX?: [number, number][];
3028
+ /** The rows of the image that stretch with `icon-text-fit`, as `[from, to]` pixels. */
3029
+ stretchY?: [number, number][];
3030
+ /** The part of the image `icon-text-fit` fits to the label: `[left, top, right, bottom]` pixels. */
3031
+ content?: [number, number, number, number];
3032
+ /** Whether a fitted image keeps the content's aspect ratio, horizontally. */
3033
+ textFitWidth?: TextFit;
3034
+ /** Whether a fitted image keeps the content's aspect ratio, vertically. */
3035
+ textFitHeight?: TextFit;
3036
+ }
3037
+ type TextFit = 'stretchOrShrink' | 'stretchOnly' | 'proportional';
3038
+ type SpriteAtlas = Map<string, SpriteEntry>;
3039
+
3040
+ /**
3041
+ * The part of a `Response` the renderer uses. A real `Response` has all of it; the type
3042
+ * is spelled out so that using this package needs neither the DOM nor Node's type
3043
+ * definitions.
3044
+ */
3045
+ interface FetchResponse {
3046
+ readonly ok: boolean;
3047
+ readonly status: number;
3048
+ readonly headers: {
3049
+ get(name: string): string | null;
3050
+ };
3051
+ arrayBuffer(): Promise<ArrayBuffer>;
3052
+ json(): Promise<unknown>;
2914
3053
  }
3054
+ /**
3055
+ * Loads a URL, like `fetch`: the renderer loads tiles, sprites, TileJSON documents and GeoJSON data through it. It is called
3056
+ * with the URL only, and should resolve to a `Response`.
3057
+ */
3058
+ type FetchFunction = (url: string) => Promise<FetchResponse>;
2915
3059
 
2916
3060
  /** Options for {@link SVGMapRenderer}: what stays the same for every view of the map. */
2917
3061
  interface SVGMapRendererOptions {
2918
3062
  /**
2919
3063
  * The MapLibre style to render.
2920
3064
  *
2921
- * Its sources must list their tile URLs directly (`tiles: [...]`). A style whose
2922
- * sources only point at a TileJSON document (`url: '.../tiles.json'`) renders as an
2923
- * **empty map without any error**, because the renderer does not fetch TileJSON. Hosted
2924
- * styles such as those of VersaTiles list their tiles; a style built with
2925
- * `@versatiles/style` needs its `inlineSources()` first.
3065
+ * A source may list its tile URLs (`tiles: [...]`) or point at a TileJSON document
3066
+ * (`url: '.../tiles.json'`), which is fetched once, like the sprite, with
3067
+ * {@link SVGMapRendererOptions.fetch}. As in MapLibre GL JS, `tiles`, `minzoom`,
3068
+ * `maxzoom` and the like come from the document unless the style sets them, and
3069
+ * relative tile URLs are resolved against the document's URL. A GeoJSON source's `data`
3070
+ * may be a URL too. A source whose TileJSON or GeoJSON cannot be loaded is left out, and
3071
+ * the next render tries again.
2926
3072
  */
2927
3073
  style: StyleSpecification;
2928
3074
  /**
2929
- * Draw the style's symbol layers: text labels and icons.
2930
- *
2931
- * Off by default, because labels are the least faithful part of the output. They are
2932
- * drawn as horizontal text at the middle of their feature: labels that MapLibre curves
2933
- * along a line (`symbol-placement: "line"`, typically street names) come out straight,
2934
- * and there is no collision detection, so crowded label layers can overlap.
2935
- *
2936
- * The SVG names each label's font (`text-font`) and leaves resolving it to whatever
2937
- * displays the SVG, so labels use the intended typeface only where that font is
2938
- * installed or provided with `@font-face`.
3075
+ * Whether and how to draw the style's symbol layers, its labels and icons:
3076
+ *
3077
+ * - `'none'`: neither labels nor icons.
3078
+ * - `'text'`: labels as `<text>` naming the style's fonts (`text-font`), which whatever
3079
+ * displays the SVG resolves, so they show in the intended typeface only where that font
3080
+ * is installed. In PNG output, with the fonts given by `fonts`.
3081
+ * - `'glyphs'`: labels as the style's own glyphs (`glyphs`), the letter shapes MapLibre
3082
+ * draws, traced into outlines: exact in every viewer and editor, but not text. Each
3083
+ * glyph is defined once and reused.
3084
+ * - `'glyphs-text'`: as `'glyphs'`, with the text laid invisibly over the outlines, so labels
3085
+ * stay selectable and searchable. (In PNG output, the same as `'glyphs'`.)
3086
+ *
3087
+ * Labels are placed as in MapLibre: at points, inside each polygon at the point farthest
3088
+ * from its edges, and along lines; labels and icons that would overlap one placed before
3089
+ * are left out, from the top layer down. With glyphs, they are laid out with MapLibre's
3090
+ * own metrics; as text, with the widths of Noto Sans. A style without `glyphs`, or glyphs
3091
+ * that cannot be loaded, fall back to `'text'`, reported through `onWarning`.
3092
+ * @defaultValue `'none'`, or as given by {@link SVGMapRendererOptions.renderLabels}
3093
+ */
3094
+ labels?: LabelMode;
3095
+ /**
3096
+ * Draw the style's labels and icons.
3097
+ * @deprecated Use {@link SVGMapRendererOptions.labels}: `true` is `'glyphs-text'`, `false`
3098
+ * is `'none'`.
2939
3099
  * @defaultValue `false`
2940
3100
  */
2941
3101
  renderLabels?: boolean;
@@ -2950,7 +3110,7 @@ interface SVGMapRendererOptions {
2950
3110
  */
2951
3111
  tileCacheSize?: number;
2952
3112
  /**
2953
- * Loads tiles and sprites, like `fetch`, which is the default. Pass your own to send
3113
+ * Loads tiles, sprites, TileJSON documents and GeoJSON data, like `fetch`, which is the default. Pass your own to send
2954
3114
  * headers, go through a proxy, or keep tiles in a cache on disk.
2955
3115
  *
2956
3116
  * It must return a real `Response`, and its status matters: a 404 or 204 means the
@@ -2960,6 +3120,24 @@ interface SVGMapRendererOptions {
2960
3120
  * @defaultValue the global `fetch`
2961
3121
  */
2962
3122
  fetch?: FetchFunction;
3123
+ /**
3124
+ * Called with a message for each part of the style the renderer does not draw: a layer
3125
+ * type, a layer property, a source, or a TileJSON document that could not be loaded. Each
3126
+ * message is reported once per instance. Pass `() => {}` to silence them.
3127
+ *
3128
+ * Properties that make no difference to a flat, north-up map (e.g. `*-pitch-alignment`)
3129
+ * are not reported, nor are symbol layers unless {@link SVGMapRendererOptions.labels}
3130
+ * is set.
3131
+ * @defaultValue `console.warn`
3132
+ */
3133
+ onWarning?: (message: string) => void;
3134
+ /**
3135
+ * Values for the style's global state, read by `global-state` expressions, e.g. to
3136
+ * switch the language or a theme of a style. They override the defaults in the style's
3137
+ * `state`, like `map.setGlobalStateProperty(name, value)` in MapLibre GL JS.
3138
+ * @defaultValue the defaults of the style's `state`
3139
+ */
3140
+ globalState?: GlobalState;
2963
3141
  }
2964
3142
  /** The view to render: size, centre and zoom. */
2965
3143
  interface ViewOptions {
@@ -2975,27 +3153,40 @@ interface ViewOptions {
2975
3153
  height?: number;
2976
3154
  /**
2977
3155
  * Longitude of the map centre, in degrees.
2978
- * @defaultValue `0`
3156
+ * @defaultValue the longitude of the style's `center`, else `0`
2979
3157
  */
2980
3158
  lon?: number;
2981
3159
  /**
2982
3160
  * Latitude of the map centre, in degrees.
2983
- * @defaultValue `0`
3161
+ * @defaultValue the latitude of the style's `center`, else `0`
2984
3162
  */
2985
3163
  lat?: number;
2986
3164
  /**
2987
3165
  * Zoom level, as in MapLibre: each step doubles the scale. Fractional values are
2988
3166
  * allowed.
2989
- * @defaultValue `2`
3167
+ * @defaultValue the style's `zoom`, else `2`
2990
3168
  */
2991
3169
  zoom?: number;
3170
+ /**
3171
+ * The compass direction that is up, in degrees, as in MapLibre: `90` puts east at the
3172
+ * top. The map turns around the image's center; labels stay upright.
3173
+ * @defaultValue the style's `bearing`, else `0`
3174
+ */
3175
+ bearing?: number;
3176
+ /**
3177
+ * Space around the map's center, in pixels, as MapLibre's `padding`: the center (`lon`,
3178
+ * `lat`) sits in the middle of the area inside it, e.g. to keep it clear of a panel laid
3179
+ * over the image. A number applies to all sides.
3180
+ * @defaultValue `0`
3181
+ */
3182
+ padding?: number | Padding;
2992
3183
  }
2993
3184
  /**
2994
3185
  * Renders many views of one MapLibre style as SVG.
2995
3186
  *
2996
3187
  * Does the work that depends only on the style once, when constructed or on the first
2997
3188
  * render, instead of on every call as {@link renderToSVG} does: the style is parsed once,
2998
- * and the sprite (the icons, needed with `renderLabels`) is fetched once. Tiles are kept
3189
+ * and the sprite (the icons, needed with `labels`) and the glyphs are fetched once. Tiles are kept
2999
3190
  * too (up to {@link SVGMapRendererOptions.tileCacheSize}), so overlapping views share
3000
3191
  * them. Use it to render a batch of views, e.g. thumbnails or a series of map sections.
3001
3192
  *
@@ -3016,8 +3207,8 @@ interface ViewOptions {
3016
3207
  declare class SVGMapRenderer {
3017
3208
  #private;
3018
3209
  /**
3019
- * @param options - The style, whether to draw labels, the tile cache size, and how to
3020
- * load tiles and sprites.
3210
+ * @param options - The style, whether to draw labels, the tile cache size, how to load
3211
+ * tiles and sprites, and where to report unsupported parts of the style.
3021
3212
  * @throws If `tileCacheSize` is negative or not a number.
3022
3213
  */
3023
3214
  constructor(options: SVGMapRendererOptions);
@@ -3031,7 +3222,7 @@ declare class SVGMapRenderer {
3031
3222
  */
3032
3223
  renderSVG(view?: ViewOptions): Promise<string>;
3033
3224
  /**
3034
- * Forgets the fetched tiles and sprite, so the next render fetches them again, e.g.
3225
+ * Forgets the fetched tiles, sprite, TileJSON documents and GeoJSON data, so the next render fetches them again, e.g.
3035
3226
  * after they were updated on the server, or to free their memory.
3036
3227
  */
3037
3228
  clearCache(): void;
@@ -3112,7 +3303,7 @@ interface RenderToSVGOptions extends Omit<SVGMapRendererOptions, 'tileCacheSize'
3112
3303
  *
3113
3304
  * @example Include labels and icons
3114
3305
  * ```ts
3115
- * const svg = await renderToSVG({ style, lon: 13.4, lat: 52.52, zoom: 14, renderLabels: true });
3306
+ * const svg = await renderToSVG({ style, lon: 13.4, lat: 52.52, zoom: 14, labels: 'glyphs-text' });
3116
3307
  * ```
3117
3308
  *
3118
3309
  * @param options - What to render and how large. Only `style` is required.
@@ -3144,7 +3335,7 @@ interface RenderToPNGOptions extends RenderToSVGOptions {
3144
3335
  * installed on the machine, which is usually not the one the style asked for.
3145
3336
  *
3146
3337
  * Fonts are registered process-wide, so a name registered by one call stays available
3147
- * to every later call. Only matters when {@link RenderToSVGOptions.renderLabels} is on.
3338
+ * to every later call. Only matters when {@link RenderToSVGOptions.labels} is `'text'`.
3148
3339
  */
3149
3340
  fonts?: Record<string, string>;
3150
3341
  }
@@ -3184,7 +3375,7 @@ interface RenderToPNGOptions extends RenderToSVGOptions {
3184
3375
  * lon: 13.4,
3185
3376
  * lat: 52.52,
3186
3377
  * zoom: 14,
3187
- * renderLabels: true,
3378
+ * labels: 'text',
3188
3379
  * fonts: { noto_sans_regular: 'fonts/NotoSans-Regular.ttf', noto_sans_bold: 'fonts/NotoSans-Bold.ttf' },
3189
3380
  * });
3190
3381
  * ```
@@ -3294,4 +3485,4 @@ declare class PNGMapRenderer extends SVGMapRenderer {
3294
3485
  }
3295
3486
 
3296
3487
  export { PNGMapRenderer, SVGMapRenderer, renderToCanvas, renderToPNG, renderToSVG };
3297
- export type { FetchFunction, FetchResponse, PNGMapRendererOptions, PNGViewOptions, RenderToPNGOptions, RenderToSVGOptions, SVGMapRendererOptions, ViewOptions };
3488
+ export type { FetchFunction, FetchResponse, GlobalState, PNGMapRendererOptions, PNGViewOptions, RenderToPNGOptions, RenderToSVGOptions, SVGMapRendererOptions, ViewOptions };