-
Notifications
You must be signed in to change notification settings - Fork 431
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
base: develop
Are you sure you want to change the base?
Conversation
- Adds `circlePane`, `polylinePane`, and `polygonPane` to `globalOptions.panes` - Maintains backwards compatibility with defaults all falling back to `overlayPane`
There was a problem hiding this 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
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | |
} |
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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' }`. | |
There was a problem hiding this comment.
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
/** 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 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove layerPane
} 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'; |
There was a problem hiding this comment.
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:
} 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'; | |
} | |
}, |
} 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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} 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'; | |
} | |
}, |
circlePane
,polylinePane
, andpolygonPane
toglobalOptions.panes
overlayPane