-
Notifications
You must be signed in to change notification settings - Fork 193
Continue a polygon anywhere #228
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -687,10 +687,13 @@ | |
// 🍂method continue() | ||
// Continue the vertex LatLngs from this vertex. Only active for first and last vertices of a Polyline. | ||
continue: function () { | ||
if (!this.editor.continueBackward) return // Only for PolylineEditor | ||
const index = this.getIndex() | ||
if (index === 0) this.editor.continueBackward(this.latlngs) | ||
else if (index === this.getLastIndex()) this.editor.continueForward(this.latlngs) | ||
if (index === 0 && this.editor.continueBackward) | ||
this.editor.continueBackward(this.latlngs) | ||
else if (index === this.getLastIndex() && this.editor.continueForward) | ||
this.editor.continueForward(this.latlngs) | ||
else if (this.editor.continueHere) | ||
this.editor.continueHere(this.latlngs, index) | ||
}, | ||
}) | ||
|
||
|
@@ -1640,6 +1643,32 @@ | |
CLOSED: true, | ||
MIN_VERTEX: 3, | ||
|
||
// 🍂method continueHere(latlngs: Array, index: int) | ||
// Set up drawing tools to continue the line forward, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe in the comment we should talk about "path" or "stroke" or even "polygon", given it does not apply for actually lines ? |
||
// after rotating the line end to the clicked vertex. | ||
continueHere: function (latlngs, index) { | ||
if (this.drawing()) return | ||
latlngs = latlngs || this.getDefaultLatLngs() | ||
this.rotateHere(latlngs, index) | ||
this.refresh() | ||
this.setDrawnLatLngs(latlngs) | ||
if (latlngs.length > 0) { | ||
this.tools.attachForwardLineGuide() | ||
this.tools.anchorForwardLineGuide(latlngs[latlngs.length - 1]) | ||
} | ||
this.startDrawingForward() | ||
}, | ||
|
||
// Make index the end of latlngs. | ||
rotateHere: function (latlngs, index) { | ||
const old = [...latlngs] | ||
const len = latlngs.length | ||
for (let i = 0; i < len; i++) { | ||
// goal: latlngs[len-1] = old[index] | ||
latlngs[i] = old[(i + index + 1) % len] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this method is touching the latlngs, I think we whould call |
||
}, | ||
|
||
newPointForward: function (latlng) { | ||
L.Editable.PathEditor.prototype.newPointForward.call(this, latlng) | ||
if (!this.tools.backwardLineGuide._latlngs.length) | ||
|
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.
Could you add brackets now that the
if
is not a one line anymore ?