diff --git a/src/renderer/edit/EditHandle.ts b/src/renderer/edit/EditHandle.ts index 2ec885a03..614108cb0 100644 --- a/src/renderer/edit/EditHandle.ts +++ b/src/renderer/edit/EditHandle.ts @@ -43,7 +43,7 @@ export default class EditHandle extends Eventable(Class) { paramOptions: Record; constructor(target: GeometryEditor, map: Map, options: EditHandleOptions) { - super(options); + super(options || {}); this.target = target; target.once('remove', this.delete, this); const symbol = this.options['symbol']; diff --git a/src/renderer/edit/EditOutline.ts b/src/renderer/edit/EditOutline.ts index e7d060a37..dda765a13 100644 --- a/src/renderer/edit/EditOutline.ts +++ b/src/renderer/edit/EditOutline.ts @@ -22,7 +22,7 @@ export default class EditOutline { this.target = target; target.once('remove', this.delete, this); this.map = map; - this.options = options; + this.options = options || {}; this.addTo(map); } diff --git a/src/renderer/map/MapCanvasRenderer.ts b/src/renderer/map/MapCanvasRenderer.ts index 5a876b4a4..2f5c13b45 100644 --- a/src/renderer/map/MapCanvasRenderer.ts +++ b/src/renderer/map/MapCanvasRenderer.ts @@ -1144,8 +1144,8 @@ class MapCanvasRenderer extends MapRenderer { sortTopElements() { this._tops = this._tops.sort((top1, top2) => { - const zIndex1 = top1.options.zIndex || 0; - const zIndex2 = top2.options.zIndex || 0; + const zIndex1 = (top1.options || {}).zIndex || 0; + const zIndex2 = (top2.options || {}).zIndex || 0; return zIndex2 - zIndex1; }); } diff --git a/test/geometry/edit/GeometryEditSpec.js b/test/geometry/edit/GeometryEditSpec.js index b613c68a2..1ca3d2785 100644 --- a/test/geometry/edit/GeometryEditSpec.js +++ b/test/geometry/edit/GeometryEditSpec.js @@ -533,5 +533,29 @@ describe('Geometry.Edit', function () { }); + it('#2452 EditOutline.options null defense', function (done) { + + const point = new maptalks.Marker([-0.131049, 51.498568, 10]).addTo(layer); + + const line = new maptalks.LineString( + [ + [-0.131049, 51.498568, 10], + [-0.107049, 51.498568, 20], + [-0.107049, 51.493568, 49], + [-0.131049, 51.493568, 22], + [-0.131049, 51.498568, 0] + ] + ).addTo(layer); + + map.setCenter(point.getCenter()); + + point.startEdit({}); + line.startEdit({}); + + done(); + + + }); + });