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

Update typescript definitions #791

Closed
wants to merge 6 commits into from
Closed
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
317 changes: 169 additions & 148 deletions leaflet-geoman.d.ts
Original file line number Diff line number Diff line change
@@ -1,164 +1,185 @@
import * as L from 'leaflet';

declare module 'leaflet' {
export interface GeomanLayerOptions {
pmIgnore?: boolean;
}

namespace PM {
export type SUPPORTED_SHAPES =
| 'Marker'
| 'Circle'
| 'Line'
| 'Rectangle'
| 'Polygon'
| 'Cut';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add CircleMarker
Is ImageOverlay missing here? They are only editable not drawable


export type GEOMAN_MAP_DRAW_MODE_EVENTS =
| 'pm:drawstart'
| 'pm:drawend'
| 'pm:create';

export type GEOMAN_MAP_EDIT_MODE_EVENTS = 'pm:globaleditmodetoggled';

export type GEOMAN_MAP_DRAG_MODE_EVENTS = 'pm:globaldrawmodetoggled';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GEOMAN_MAP_DRAG_MODE_EVENTS = 'pm:globaldrawmodetoggled';
export type GEOMAN_MAP_DRAG_MODE_EVENTS = 'pm:globaldragmodetoggled';


export type GEOMAN_MAP_REMOVAL_MODE_EVENTS = 'pm:globalremovalmodetoggled';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globaldrawmodetoggled is missing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GEOMAN_MAP_REMOVAL_MODE_EVENTS = 'pm:globalremovalmodetoggled';
export type GEOMAN_MAP_REMOVAL_MODE_EVENTS = 'pm:globalremovalmodetoggled' | 'pm:remove' | 'layerremove';

https://github.com/geoman-io/leaflet-geoman/tree/develop#removal-mode


export type GEOMAN_MAP_CUT_MODE_EVENTS = 'pm:cut';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GEOMAN_MAP_CUT_MODE_EVENTS = 'pm:cut';
export type GEOMAN_MAP_CUT_MODE_EVENTS = 'pm:cut' | 'pm:globalcutmodetoggled';


export type GEOMAN_LAYER_DRAW_MODE_EVENTS =
| 'pm:vertexadded'
| 'pm:snapdrag'
| 'pm:snap'
| 'pm:unsnap'
| 'pm:centerplaced';

export type GEOMAN_LAYER_EDIT_MODE_EVENTS =
| 'pm:edit'
| 'pm:vertexadded'
| 'pm:vertexremoved'
| 'pm:markerdragstart'
| 'pm:markerdragend'
| 'pm:snap'
| 'pm:unsnap'
| 'pm:intersect'
| 'pm:centerplaced';
Comment on lines +37 to +46
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GEOMAN_LAYER_EDIT_MODE_EVENTS =
| 'pm:edit'
| 'pm:vertexadded'
| 'pm:vertexremoved'
| 'pm:markerdragstart'
| 'pm:markerdragend'
| 'pm:snap'
| 'pm:unsnap'
| 'pm:intersect'
| 'pm:centerplaced';
export type GEOMAN_LAYER_EDIT_MODE_EVENTS =
| 'pm:edit'
| 'pm:update'
| 'pm:enable'
| 'pm:disable'
| 'pm:vertexadded'
| 'pm:vertexremoved'
| 'pm:vertexclick'
| 'pm:markerdragstart'
| 'pm:markerdrag'
| 'pm:markerdragend'
| 'pm:layerrest'
| 'pm:snapdrag'
| 'pm:snap'
| 'pm:unsnap'
| 'pm:intersect'
| 'pm:centerplaced';


export type GEOMAN_LAYER_DRAG_MODE_EVENTS =
| 'pm:dragstart'
| 'pm:drag'
| 'pm:dragend';

export type GEOMAN_LAYER_CUT_MODE_EVENTS = 'pm:cut';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GEOMAN_LAYER_CUT_MODE_EVENTS = 'pm:cut';
export type GEOMAN_LAYER_CUT_MODE_EVENTS = 'pm:cut' | 'pm:edit'

https://github.com/geoman-io/leaflet-geoman/tree/develop#cut-mode


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pm:buttonclick and pm:actionclick are missing
https://github.com/geoman-io/leaflet-geoman/tree/develop#actions

export interface GeomanHelpers {
getShapes(): string[];
}

export interface GeomanLayerOptions {
pmIgnore?: boolean;
export class MapDrawOptions {
snappable?: boolean;
snapDistance?: number;
snapMiddle?: boolean;
tooltips?: boolean;
allowSelfIntersection?: true;
templineStyle?: L.PathOptions;
hintlineStyle?: L.PathOptions;
cursorMarker?: boolean;
finishOn?:
| null
| 'click'
| 'dblclick'
| 'mousedown'
| 'mouseover'
| 'mouseout'
| 'contextmenu';
Comment on lines +59 to +75
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class MapDrawOptions {
snappable?: boolean;
snapDistance?: number;
snapMiddle?: boolean;
tooltips?: boolean;
allowSelfIntersection?: true;
templineStyle?: L.PathOptions;
hintlineStyle?: L.PathOptions;
cursorMarker?: boolean;
finishOn?:
| null
| 'click'
| 'dblclick'
| 'mousedown'
| 'mouseover'
| 'mouseout'
| 'contextmenu';
export class MapDrawOptions {
snappable?: boolean;
snapDistance?: number;
snapMiddle?: boolean;
tooltips?: boolean;
allowSelfIntersection?: true;
templineStyle?: L.PathOptions;
hintlineStyle?: L.PathOptions;
pathOptions?: L.PathOptions;
markerStyle?: ?????????????????
cursorMarker?: boolean;
finishOn?:
| null
| 'click'
| 'dblclick'
| 'mousedown'
| 'mouseover'
| 'mouseout'
| 'contextmenu'
| 'snap';
hideMiddleMarkers?: boolean;
minRadiusCircle?: number;
maxRadiusCircle?: number;
minRadiusCircleMarker?: number;
maxRadiusCircleMarker?: number;
editable?: boolean;
markerEditable?: boolean;
continueDrawing?: boolean;
layerGroup?: ????????? void? Can be map but also a L.LayerGroup

Maybe this should named not map, because the options applied to the drawing layer and not to the map

}

namespace PM {
export type SUPPORTED_SHAPES = (
'Marker' | 'Circle' | 'Line' |
'Rectangle' | 'Polygon' | 'Cut'
);

export type GEOMAN_MAP_DRAW_MODE_EVENTS = (
'pm:drawstart' | 'pm:drawend' | 'pm:create'
);

export type GEOMAN_MAP_EDIT_MODE_EVENTS = (
'pm:globaleditmodetoggled'
);

export type GEOMAN_MAP_DRAG_MODE_EVENTS = (
'pm:globaldrawmodetoggled'
);

export type GEOMAN_MAP_REMOVAL_MODE_EVENTS = (
'pm:globalremovalmodetoggled'
);

export type GEOMAN_MAP_CUT_MODE_EVENTS = (
'pm:cut'
);

export type GEOMAN_LAYER_DRAW_MODE_EVENTS = (
'pm:vertexadded' | 'pm:snapdrag' |
'pm:snap' | 'pm:unsnap' |
'pm:centerplaced'
);

export type GEOMAN_LAYER_EDIT_MODE_EVENTS = (
'pm:edit' | 'pm:vertexadded' | 'pm:vertexremoved' |
'pm:markerdragstart' | 'pm:markerdragend' | 'pm:snap' |
'pm:unsnap' | 'pm:intersect' | 'pm:centerplaced'
);

export type GEOMAN_LAYER_DRAG_MODE_EVENTS = (
'pm:dragstart' | 'pm:drag' | 'pm:dragend'
);

export type GEOMAN_LAYER_CUT_MODE_EVENTS = (
'pm:cut'
);

export interface GeomanHelpers {
getShapes(): string[];
}

export class MapDrawOptions {
snappable?: boolean;
snapDistance?: number;
snapMiddle?: boolean;
tooltips?: boolean;
allowSelfIntersection?: true;
templineStyle?: L.PathOptions;
hintlineStyle?: L.PathOptions;
cursorMarker?: boolean;
finishOn?: null | 'click' | 'dblclick' | 'mousedown' | 'mouseover' | 'mouseout' | 'contextmenu';
}

export class LayerDrawOptions {
snappable?: boolean;
snapDistance?: number;
allowSelfIntersection?: boolean;
preventMarkerRemoval?: boolean;
}

export class DrawControlOptions {
position?: ControlPosition;
drawMarker?: boolean;
drawCircleMarker?: boolean;
drawPolyline?: boolean;
drawRectangle?: boolean;
drawPolygon?: boolean;
drawCircle?: boolean;
editMode?: boolean;
dragMode?: boolean;
cutPolygon?: boolean;
removalMode?: boolean;
}

export function initialize(options?: { optIn: boolean }): void;

export class Translations {
tooltips?: {
placeMarker?: string;
firstVertex?: string;
continueLine?: string;
finishLine?: string;
finishPoly?: string;
finishRect?: string;
startCircle?: string;
finishCircle?: string;
placeCircleMarker?: string;
};

actions?: {
finish?: string;
cancel?: string;
removeLastVertex?: string;
};

buttonTitles?: {
drawMarkerButton?: string;
drawPolyButton?: string;
drawLineButton?: string;
drawCircleButton?: string;
drawRectButton?: string;
editButton?: string;
dragButton?: string;
cutButton?: string;
deleteButton?: string;
drawCircleMarkerButton?: string;
};
}

interface Map {
addControls(options?: DrawControlOptions): void;
enableDraw(shape: SUPPORTED_SHAPES, options?: MapDrawOptions): void;
disableDraw(shape: SUPPORTED_SHAPES): void;
enableGlobalEditMode(options): void;
disableGlobalEditMode(): void;
toggleGlobalEditMode(options): void;
globalEditEnabled(): boolean;
setLang(lang: 'en' | 'de' | 'it' | 'ru' | 'ro' | 'es' | 'fr' | 'pt_br' | 'zh' | 'nl', customTranslations?: Translations, fallbackLanguage?: string);
setPathOptions(options: PathOptions): void;
Draw: GeomanHelpers;
}

interface Layer {
enable(options?: LayerDrawOptions): void;
disable(): void;
toggleEdit(options?: LayerDrawOptions): void;
enabled(): boolean;
hasSelfIntersection(): boolean;
}
export class LayerDrawOptions {
snappable?: boolean;
snapDistance?: number;
allowSelfIntersection?: boolean;
preventMarkerRemoval?: boolean;
Comment on lines +78 to +82
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class LayerDrawOptions {
snappable?: boolean;
snapDistance?: number;
allowSelfIntersection?: boolean;
preventMarkerRemoval?: boolean;
export class LayerDrawOptions {
snappable?: boolean;
snapDistance?: number;
allowSelfIntersection?: boolean;
allowSelfIntersectionEdit?: boolean;
preventMarkerRemoval?: boolean;
removeLayerBelowMinVertexCount?: boolean;
limitMarkersToCount?: number;
limitMarkersToZoom?: number;
limitMarkersToViewport?: boolean;
limitMarkersToClick?: boolean;
pinning?: boolean;

Maybe this should named EditOptions because it is for edit mode

}

interface Map {
pm: PM.Map;
export class DrawControlOptions {
position?: ControlPosition;
drawMarker?: boolean;
drawCircleMarker?: boolean;
drawPolyline?: boolean;
drawRectangle?: boolean;
drawPolygon?: boolean;
drawCircle?: boolean;
editMode?: boolean;
dragMode?: boolean;
cutPolygon?: boolean;
removalMode?: boolean;
Comment on lines +85 to +96
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in current develop version

}

interface Layer {
pm: PM.Layer
export function initialize(options?: { optIn: boolean }): void;

export class Translations {
tooltips?: {
placeMarker?: string;
firstVertex?: string;
continueLine?: string;
finishLine?: string;
finishPoly?: string;
finishRect?: string;
startCircle?: string;
finishCircle?: string;
placeCircleMarker?: string;
};

actions?: {
finish?: string;
cancel?: string;
removeLastVertex?: string;
};

buttonTitles?: {
drawMarkerButton?: string;
drawPolyButton?: string;
drawLineButton?: string;
drawCircleButton?: string;
drawRectButton?: string;
editButton?: string;
dragButton?: string;
cutButton?: string;
deleteButton?: string;
drawCircleMarkerButton?: string;
};
}

interface LayerOptions {
pmIgnore?: boolean
interface Map {
addControls(options?: DrawControlOptions): void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • controlsVisible()
  • globalCutModeEnabled
  • enableGlobalCutMode
  • toggleGlobalCutMode
  • disableGlobalCutMode
  • globalEditModeEnabled
  • enableGlobalDragMode
  • disableGlobalDragMode
  • globalDragModeEnabled
  • toggleGlobalDragMode
  • enableGlobalRemovalMode
  • disableGlobalRemovalMode
  • globalRemovalModeEnabled
  • toggleGlobalRemovalMode

#821

enableDraw(shape: SUPPORTED_SHAPES, options?: MapDrawOptions): void;
disableDraw(shape: SUPPORTED_SHAPES): void;
enableGlobalEditMode(options): void;
disableGlobalEditMode(): void;
toggleGlobalEditMode(options): void;
globalEditEnabled(): boolean;
setLang(
lang:
| 'en'
| 'de'
| 'it'
| 'ru'
| 'ro'
| 'es'
| 'fr'
| 'pt_br'
| 'zh'
| 'nl',
Comment on lines +143 to +153
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lang:
| 'en'
| 'de'
| 'it'
| 'ru'
| 'ro'
| 'es'
| 'fr'
| 'pt_br'
| 'zh'
| 'nl',
lang:
| 'da'
| 'de'
| 'el'
| 'en'
| 'es'
| 'fa'
| 'fr'
| 'hu'
| 'id'
| 'it'
| 'nl'
| 'no'
| 'pl'
| 'pt_br'
| 'ro'
| 'ru'
| 'sv'
| 'tr'
| 'ua'
| 'zh'
| 'zh_tw';

customTranslations?: Translations,
fallbackLanguage?: string
);
setPathOptions(options: PathOptions): void;
Draw: GeomanHelpers;
}

interface MapOptions {
pmIgnore?: boolean;
interface Layer {
enable(options?: LayerDrawOptions): void;
disable(): void;
toggleEdit(options?: LayerDrawOptions): void;
enabled(): boolean;
hasSelfIntersection(): boolean;
}
}

interface Map {
pm: PM.Map;
}

interface Layer {
pm: PM.Layer;
}

interface LayerOptions {
pmIgnore?: boolean;
}

interface MapOptions {
pmIgnore?: boolean;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface PM

  • reInitLayer()
  • setOptIn

}