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

option to further customize panes #1272

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

TurtIeSocks
Copy link
Contributor

  • Adds circlePane, polylinePane, and polygonPane to globalOptions.panes
  • Maintains backwards compatibility with defaults all falling back to overlayPane

- Adds `circlePane`, `polylinePane`, and `polygonPane` to `globalOptions.panes`
- Maintains backwards compatibility with defaults all falling back to `overlayPane`
Copy link
Collaborator

@Falke-Design Falke-Design left a comment

Choose a reason for hiding this comment

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

Thank you for adding this, can you please add a option for every shape. CircleMarker, Text, Rectangle

Comment on lines +143 to +151
if (o.panes && o.panes.layerPane && !o.panes.circleMarkerPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.rectanglePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.textPane) {
options.panes.circlePane = o.panes.markerPane;
}
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
if (o.panes && o.panes.layerPane && !o.panes.circleMarkerPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.rectanglePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.textPane) {
options.panes.circlePane = o.panes.markerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.circleMarkerPane) {
options.panes.circleMarkerPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.rectanglePane) {
options.panes.rectanglePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.textPane) {
options.panes.textPane = o.panes.markerPane;
}

Comment on lines +134 to +151
if (o.panes && o.panes.layerPane && !o.panes.polygonPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.polylinePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.circlePane) {
options.panes.circlePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.circleMarkerPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.rectanglePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.textPane) {
options.panes.circlePane = o.panes.markerPane;
}
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
if (o.panes && o.panes.layerPane && !o.panes.polygonPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.polylinePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.circlePane) {
options.panes.circlePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.circleMarkerPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.rectanglePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (o.panes && o.panes.layerPane && !o.panes.textPane) {
options.panes.circlePane = o.panes.markerPane;
}
if (o.panes) {
if(o.panes.layerPane){
if(!o.panes.polygonPane) {
options.panes.polygonPane = o.panes.layerPane;
}
if (!o.panes.polylinePane) {
options.panes.polylinePane = o.panes.layerPane;
}
if (!o.panes.circlePane) {
options.panes.circlePane = o.panes.layerPane;
}
if (!o.panes.circleMarkerPane) {
options.panes.circleMarkerPane = o.panes.layerPane;
}
if (!o.panes.rectanglePane) {
options.panes.rectanglePane= o.panes.layerPane;
}
}
if (o.panes.markerPane && !o.panes.textPane) {
options.panes.textPane = o.panes.markerPane;
}
}

| :------------ | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| snappingOrder | `Array` | Prioritize the order of snapping. Default: `['Marker','CircleMarker','Circle','Line','Polygon','Rectangle']`. |
| layerGroup | `map` | add the created layers to a layergroup instead to the map. |
| panes | `Object` | Defines in which [panes](https://leafletjs.com/reference.html#map-pane) the layers and helper vertices are created. Default: `{ vertexPane: 'markerPane', layerPane: 'overlayPane', markerPane: 'markerPane', circlePane: 'overlayPane', polylinePane: 'overlayPane', polygonPane: 'overlayPane', circleMarkerPane: 'overlayPane', rectanglePane: 'overlayPane', textPane: 'markerPane' }`. |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let us remove layerPane from the docs because it is now deprecated, but keep the logic in L.PM.Edit with a deprecated comment

Comment on lines +773 to +774
/** Defines in which panes the layers and helper vertices are created. Default: { vertexPane: 'markerPane', layerPane: 'overlayPane', markerPane: 'markerPane', circlePane: 'overlayPane', polygonPane: 'overlayPane', polylinePane: 'overlayPane' } */
panes?: { vertexPane?: PANE; layerPane?: PANE; markerPane?: PANE, circlePane?: PANE, polygonPane?: PANE, polylinePane?: PANE, circleMarkerPane?: PANE, rectanglePane?: PANE, textPane?: PANE };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove layerPane

Comment on lines +222 to +257
} else if (type === 'polygonPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polygonPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circlePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circlePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circleMarkerPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circleMarkerPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'polylinePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polylinePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'rectanglePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.rectanglePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'textPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.textPane ||
this._map.pm.globalOptions.panes.markerPane)) ||
'markerPane';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let us simplify this a little bit:

Suggested change
} else if (type === 'polygonPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polygonPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circlePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circlePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circleMarkerPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circleMarkerPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'polylinePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polylinePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'rectanglePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.rectanglePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'textPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.textPane ||
this._map.pm.globalOptions.panes.markerPane)) ||
'markerPane';
_setPane(layer, type) {
const panes = this._map.pm.globalOptions.panes || {};
if (type === 'layerPane') {
layer.options.pane = panes.layerPane || 'overlayPane';
} else if (type === 'vertexPane') {
layer.options.pane = panes.vertexPane || 'markerPane';
} else if (type === 'markerPane') {
layer.options.pane = panes.markerPane || 'markerPane';
}
},

Comment on lines +60 to +95
} else if (type === 'polygonPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polygonPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circlePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circlePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circleMarkerPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circleMarkerPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'polylinePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polylinePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'rectanglePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.rectanglePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'textPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.textPane ||
this._map.pm.globalOptions.panes.markerPane)) ||
'markerPane';
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
} else if (type === 'polygonPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polygonPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circlePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circlePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'circleMarkerPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.circleMarkerPane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'polylinePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.polylinePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'rectanglePane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.rectanglePane ||
this._map.pm.globalOptions.panes.layerPane)) ||
'overlayPane';
} else if (type === 'textPane') {
layer.options.pane =
(this._map.pm.globalOptions.panes &&
(this._map.pm.globalOptions.panes.textPane ||
this._map.pm.globalOptions.panes.markerPane)) ||
'markerPane';
_setPane(layer, type) {
const panes = this._map.pm.globalOptions.panes || {};
if (type === 'layerPane') {
layer.options.pane = panes.layerPane || 'overlayPane';
} else if (type === 'vertexPane') {
layer.options.pane = panes.vertexPane || 'markerPane';
} else if (type === 'markerPane') {
layer.options.pane = panes.markerPane || 'markerPane';
}
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants