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

options.offset type is incomplete in both style/FillPattern and style/StrokePattern #128

Merged
merged 6 commits into from
Jun 10, 2023
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
2 changes: 1 addition & 1 deletion @types/ol-ext/control/LayerSwitcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface Options extends ControlOptions {
reordering?: boolean;
trash?: boolean;
oninfo?: (l: Layer) => void;
extent?: Extent;
extent?: boolean;
onExtent?: (l: Layer) => void;
drawDelay?: number;
collapsed?: boolean;
Expand Down
24 changes: 19 additions & 5 deletions @types/ol-ext/legend/Item.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type BaseObject from 'ol/Object';
import type Feature from 'ol/Feature'
import type { StyleLike } from 'ol/style/Style'
import type { Size } from 'ol/size'
Expand All @@ -11,7 +12,7 @@ export type olLegendItemOptions = {
* row title
*/
title: string;
className: string;
className?: string;
/**
* a feature to draw on the legend
*/
Expand All @@ -25,10 +26,21 @@ export type olLegendItemOptions = {
*/
properties?: any;
/**
* a style or a style function to use to draw the legend
* a style or a style function to use to draw the legend symbol
*/
style: StyleLike;
textStyle: Text
style?: StyleLike;
/**
* a text style to draw the item title in the legend
*/
textStyle?: Text;
/**
* the symbol width, default use the default width
*/
width?: number;
/**
* the symbol height, default use the default height
*/
height?: number;
size?: Size
margin?: number
};
Expand All @@ -41,6 +53,8 @@ export type olLegendItemOptions = {
* @property {Object} properties a set of properties to use with a style function
* @property {StyleLike} style a style or a style function to use to draw the legend symbol
* @property {Text} textStyle a text style to draw the item title in the legend
* @property {number|undefined} width the symbol width, default use the default width
* @property {number|undefined} height the symbol height, default use the default height
* @property {Size|undefined} size
* @property {number|undefined} margin
*/
Expand All @@ -49,7 +63,7 @@ export type olLegendItemOptions = {
* @constructor
* @fires select
*/
export default class LegendItem {
export default class LegendItem extends BaseObject {
/**
* @param {olLegendItemOptions} options
*/
Expand Down
17 changes: 15 additions & 2 deletions @types/ol-ext/legend/Legend.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Size } from 'ol/size'
import type Layer from 'ol/layer/Layer'
import type ol_legend_Item from './Item'
import type { olLegendItemOptions } from './Item'
import type BaseObject from 'ol/Object';

export interface Options {
title?: string;
Expand All @@ -22,7 +23,7 @@ export interface Options {
* @fires select
* @fires refresh
*/
export default class ol_legend_Legend {
export default class ol_legend_Legend extends BaseObject {
/** Get a symbol image for a given legend item
* @param {olLegendItemOptions} item
* @param {Canvas|undefined} canvas a canvas to draw in, if none creat one
Expand Down Expand Up @@ -66,7 +67,7 @@ export default class ol_legend_Legend {
/** Set legend size
* @param {ol.size} size
*/
set(key: any, value: any, opt_silent: any): void;
set(size: Size): void;

/** Get legend list element
* @returns {Element}
Expand Down Expand Up @@ -124,4 +125,16 @@ export default class ol_legend_Legend {
* @return {CanvasElement}
*/
getLegendImage(item: olLegendItemOptions, canvas?: HTMLCanvasElement, offsetY?: number): HTMLCanvasElement;

// The following function is already declared in ol/Object.d.ts
// but we still have to redeclare it here, otherwise it's being hidden
// by set(size: Size), which is declared above.
/**
* Sets a value.
* @param {string} key Key name.
* @param {*} value Value.
* @param {boolean} [opt_silent] Update without triggering an event.
* @api
*/
set(key: string, value: any, opt_silent?: boolean | undefined): void;
}
4 changes: 2 additions & 2 deletions @types/ol-ext/style/FillPattern.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Options {
opacity?: number;
color?: Color | ColorLike;
fill?: Fill;
offset?: number;
offset?: number | [number, number];
size?: number;
spacing?: number;
angle?: number | boolean;
Expand All @@ -48,7 +48,7 @@ export default class FillPattern extends Fill {
* @param {string} options.pattern pattern name (override by image option)
* @param {Color|ColorLike} options.color pattern color
* @param {Fill} options.fill fill color (background)
* @param {number} options.offset pattern offset for hash/dot/circle/cross pattern
* @param {number|Array<number>} options.offset pattern offset for hash/dot/circle/cross pattern
* @param {number} options.size line size for hash/dot/circle/cross pattern
* @param {number} options.spacing spacing for hash/dot/circle/cross pattern
* @param {number|boolean} options.angle angle for hash pattern / true for 45deg dot/circle/cross
Expand Down
6 changes: 3 additions & 3 deletions @types/ol-ext/style/StrokePattern.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export interface Options {
pattern?: string;
color?: ColorLike;
fill?: Fill;
offset?: number;
Size?: number;
offset?: number | [number, number];
size?: number;
spacing?: number;
angle?: number | boolean;
scale?: number;
Expand All @@ -32,7 +32,7 @@ export default class StrokePattern extends Stroke {
* @param {string} options.pattern pattern name (override by image option)
* @param {ColorLike} options.color pattern color
* @param {Fill} options.fill fill color (background)
* @param {number} options.offset pattern offset for hash/dot/circle/cross pattern
* @param {number|Array<number>} options.offset pattern offset for hash/dot/circle/cross pattern
* @param {number} options.size line size for hash/dot/circle/cross pattern
* @param {number} options.spacing spacing for hash/dot/circle/cross pattern
* @param {number|boolean} options.angle angle for hash pattern / true for 45deg dot/circle/cross
Expand Down