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

Backport Pro changes into OSS #1490

Merged
merged 1 commit into from
May 3, 2024
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
33 changes: 33 additions & 0 deletions cypress/integration/line.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,37 @@ describe('Draw & Edit Line', () => {
expect(hintLine.options.color).to.eql('red');
});
});

it('remove vertex marker from MarkerLimit Cache', () => {
cy.toolbarButton('polyline').click();

cy.get(mapSelector)
.click(120, 150)
.click(120, 100)
.click(300, 100)
.click(300, 200)
.click(120, 150);

cy.toolbarButton('edit').click();

cy.hasVertexMarkers(4);
cy.hasMiddleMarkers(3);

// rightclick on a vertex-marker to delete it
cy.get('.marker-icon:not(.marker-icon-middle)')
.eq(2)
.trigger('contextmenu');

cy.hasVertexMarkers(3);
cy.hasMiddleMarkers(2);

cy.wait(20);

cy.window().then(({ map }) => {
map.panBy([40, 40], { animate: false });
});

cy.hasVertexMarkers(3);
cy.hasMiddleMarkers(2);
});
});
216 changes: 209 additions & 7 deletions leaflet-geoman.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,66 @@ declare module 'leaflet' {
fn?: PM.GlobalRotateModeToggledEventHandler
): this;

/******************************************
*
* TODO: Union MODE EVENTS ON MAP ONLY
*
********************************************/

/** Fired when Union Mode is toggled. */
on(
type: 'pm:globalunionmodetoggled',
fn: PM.GlobalUnionModeToggledEventHandler
): this;
once(
type: 'pm:globalunionmodetoggled',
fn: PM.GlobalUnionModeToggledEventHandler
): this;
off(
type: 'pm:globalunionmodetoggled',
fn?: PM.GlobalUnionModeToggledEventHandler
): this;

/** Fired when Union is executed. */
on(type: 'pm:union', fn: PM.UnionEventHandler): this;
once(type: 'pm:union', fn: PM.UnionEventHandler): this;
off(type: 'pm:union', fn: PM.UnionEventHandler): this;

/******************************************
*
* TODO: Difference MODE EVENTS ON MAP ONLY
*
********************************************/

/** Fired when Difference Mode is toggled. */
on(
type: 'pm:globaldifferencemodetoggled',
fn: PM.GlobalDifferenceModeToggledEventHandler
): this;
once(
type: 'pm:globaldifferencemodetoggled',
fn: PM.GlobalDifferenceModeToggledEventHandler
): this;
off(
type: 'pm:globaldifferencemodetoggled',
fn?: PM.GlobalDifferenceModeToggledEventHandler
): this;

/** Fired when Difference is executed. */
on(type: 'pm:difference', fn: PM.DifferenceEventHandler): this;
once(type: 'pm:difference', fn: PM.DifferenceEventHandler): this;
off(type: 'pm:difference', fn?: PM.DifferenceEventHandler): this;

/** Fired when a layer is added to the selection. */
on(type: 'pm:selectionadd', fn: PM.SelectionEventHandler): this;
once(type: 'pm:selectionadd', fn: PM.SelectionEventHandler): this;
off(type: 'pm:selectionadd', fn: PM.SelectionEventHandler): this;

/** Fired when a layer is removed from the selection. */
on(type: 'pm:selectionremove', fn: PM.SelectionEventHandler): this;
once(type: 'pm:selectionremove', fn: PM.SelectionEventHandler): this;
off(type: 'pm:selectionremove', fn: PM.SelectionEventHandler): this;

/******************************************
*
* TODO: TRANSLATION EVENTS ON MAP ONLY
Expand Down Expand Up @@ -479,7 +539,6 @@ declare module 'leaflet' {
}

namespace PM {

export const version: string;

/** Supported shape names. 'ImageOverlay' is in Edit Mode only. Also accepts custom shape name. */
Expand Down Expand Up @@ -547,7 +606,11 @@ declare module 'leaflet' {
PMDragMap,
PMRemoveMap,
PMCutMap,
PMRotateMap {
PMRotateMap,
PMScaleMap,
PMSelectionMap,
PMUnionMap,
PMDifferenceMap {
Toolbar: PMMapToolbar;

Keyboard: PMMapKeyboard;
Expand Down Expand Up @@ -592,6 +655,8 @@ declare module 'leaflet' {
finishCircle?: string;
placeCircleMarker?: string;
placeText?: string;
selectFirstLayerFor?: string;
selectSecondLayerFor?: string;
};

actions?: {
Expand All @@ -617,6 +682,9 @@ declare module 'leaflet' {
drawTextButton?: string;
scaleButton?: string;
autoTracingButton?: string;
snapGuidesButton?: string;
unionButton?: string;
differenceButton?: string;
};

measurements?: {
Expand All @@ -629,14 +697,15 @@ declare module 'leaflet' {
width?: string;
coordinates?: string;
coordinatesMarker?: string;
}
};
}

type ACTION_NAMES = 'cancel' | 'removeLastVertex' | 'finish' | 'finishMode';

class Action {
text: string;
onClick?: (e: any) => void;
title?: string;
}

type TOOLBAR_CONTROL_ORDER =
Expand All @@ -652,6 +721,14 @@ declare module 'leaflet' {
| 'removalMode'
| 'rotateMode'
| 'drawText'
| 'scaleMode'
| 'pinningOption'
| 'snappingOption'
| 'autoTracingOption'
| 'snapGuidesOption'
| 'spitalMode'
| 'unionMode'
| 'differenceMode'
| string;

interface PMMapToolbar {
Expand All @@ -668,7 +745,7 @@ declare module 'leaflet' {
): void;

/** Returns all of the active buttons */
getButtons(): Record<string, L.Control>
getButtons(): Record<string, L.Control>;

/** Returns the full button object or undefined if the name does not exist */
getButton(name: string): L.Control | undefined;
Expand All @@ -677,7 +754,7 @@ declare module 'leaflet' {
controlExists(name: string): boolean;

/** Returns all of the custom, active buttons */
getButtonsInBlock(name: string): Record<string, L.Control>
getButtonsInBlock(name: string): Record<string, L.Control>;

/** Returns a Object with the positions for all blocks */
getBlockPositions(): BlockPositions;
Expand All @@ -690,8 +767,8 @@ declare module 'leaflet' {
copyInstance: string,
options?: CustomControlOptions
): {
drawInstance: Draw,
control: L.Control
drawInstance: Draw;
control: L.Control;
};

/** Change the actions of an existing button. */
Expand Down Expand Up @@ -808,6 +885,26 @@ declare module 'leaflet' {

/** Defines in which panes the layers and helper vertices are created. Default: { vertexPane: 'markerPane', layerPane: 'overlayPane', markerPane: 'markerPane' } */
panes?: { vertexPane?: PANE; layerPane?: PANE; markerPane?: PANE };

/** Measurement options */
measurements?: {
measurement?: boolean;
showTooltip?: boolean;
showTooltipOnHover?: boolean;
totalLength?: boolean;
segmentLength?: boolean;
area?: boolean;
radius?: boolean;
perimeter?: boolean;
height?: boolean;
width?: boolean;
coordinates?: boolean;
displayFormat?: 'metric' | 'imperial';
};

autoTracing?: boolean;

selectionLayerStyle?: L.PathOptions;
}

interface PMDrawMap {
Expand Down Expand Up @@ -908,6 +1005,74 @@ declare module 'leaflet' {
globalRotateModeEnabled(): boolean;
}

interface PMScaleMap {
/** Enables global scale mode. */
enableGlobalScaleMode(): void;

/** Disables global scale mode. */
disableGlobalScaleMode(): void;

/** Toggles global scale mode. */
toggleGlobalScaleMode(): void;

/** Returns true if global scale mode is enabled. false when disabled. */
globalScaleModeEnabled(): boolean;
}

interface PMSelectionMap {
/** Enables global selection mode. Optional a filter can be added, which checks if the selection is allowed. */
enableSelectionTool(filterFnc?: () => boolean): void;

/** Disables global selection mode. */
disableSelectionTool(): void;

/** Returns true if global selection mode is enabled. false when disabled. */
selectionToolEnabled(): boolean;

/** Adds a layer to the selection. */
addSelection(layer: L.Layer): void;

/** Removes a layer from the selection. */
removeSelection(layer: L.Layer): void;

/** Returns selected layers. */
getSelectedLayers(): L.Layer[];
}

interface PMUnionMap {
/** Enables global union mode. */
enableGlobalUnionMode(): void;

/** Disables global union mode. */
disableGlobalUnionMode(): void;

/** Toggles global union mode. */
toggleGlobalUnionMode(): void;

/** Returns true if global union mode is enabled. false when disabled. */
globalUnionModeEnabled(): boolean;

/** Unifies the two layers. */
union(layer1: L.Layer, layer2: L.Layer): void;
}

interface PMDifferenceMap {
/** Enables global difference mode. */
enableGlobalDifferenceMode(): void;

/** Disables global difference mode. */
disableGlobalDifferenceMode(): void;

/** Toggles global difference mode. */
toggleGlobalDifferenceMode(): void;

/** Returns true if global difference mode is enabled. false when disabled. */
globalDifferenceModeEnabled(): boolean;

/** Subtracts the second selected layer from the first selected layer. */
difference(layer1: L.Layer, layer2: L.Layer): void;
}

interface PMRotateLayer {
/** Enables rotate mode on the layer. */
enableRotate(): void;
Expand Down Expand Up @@ -1614,6 +1779,43 @@ declare module 'leaflet' {
map: L.Map;
}) => void;

/**
* UNION MODE MAP EVENT HANDLERS
*/
export type GlobalUnionModeToggledEventHandler = (e: {
enabled: boolean;
map: L.Map;
}) => void;

/**
* UNION EVENT HANDLERS
*/
export type UnionEventHandler = (e: {
resultLayer: L.Layer;
mergedLayers: L.Layer[];
}) => void;

/**
* DIFFERENCE MODE MAP EVENT HANDLERS
*/
export type GlobalDifferenceModeToggledEventHandler = (e: {
enabled: boolean;
map: L.Map;
}) => void;

/**
* DIFFERENCE EVENT HANDLERS
*/
export type DifferenceEventHandler = (e: {
resultLayer: L.Layer;
subtractedLayers: L.Layer[];
}) => void;

/**
* SELECTION EVENT HANDLERS
*/
export type SelectionEventHandler = (e: { layer: L.Layer }) => void;

/**
* TRANSLATION EVENT HANDLERS
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@turf/line-intersect": "^6.5.0",
"@turf/line-split": "^6.5.0",
"lodash": "4.17.21",
"polygon-clipping": "0.15.3"
"polyclip-ts": "^0.16.5"
},
"devDependencies": {
"@types/leaflet": "^1.7.9",
Expand Down
Loading