Skip to content

Commit

Permalink
Add option to disable first/last marker of polyline (ibrierley#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
leiflinse-trivector committed Apr 8, 2024
1 parent 753e326 commit 6dba9ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var polyEditor = PolyEditor(
intermediateIcon: Icon(Icons.lens, size: 15, color: Colors.grey),
callbackRefresh: () => { this.setState(() {})},
addClosePathMarker: false, // set to true if polygon
addLineStartMarker: true, // set to false, to remove first marker of line
addLineEndMarker: true, // set to false, to remove last marker of line
);
```

Expand Down
10 changes: 9 additions & 1 deletion lib/src/poly_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ class PolyEditor {
final Size intermediateIconSize;
final void Function(LatLng? updatePoint)? callbackRefresh;
final bool addClosePathMarker;
final bool addLineStartMarker;
final bool addLineEndMarker;

PolyEditor({
required this.points,
required this.pointIcon,
this.intermediateIcon,
this.callbackRefresh,
this.addLineStartMarker = false,
this.addLineEndMarker = false,
this.addClosePathMarker = false,
this.pointIconSize = const Size(30, 30),
this.intermediateIconSize = const Size(30, 30),
Expand Down Expand Up @@ -45,7 +49,11 @@ class PolyEditor {
List<DragMarker> edit() {
List<DragMarker> dragMarkers = [];

for (var c = 0; c < points.length; c++) {
final startC = addLineStartMarker || addClosePathMarker ? 0 : 1;
final endC = addLineEndMarker || addClosePathMarker
? points.length
: points.length - 1;
for (var c = startC; c < endC; c++) {
final indexClosure = c;
dragMarkers.add(DragMarker(
point: points[c],
Expand Down

0 comments on commit 6dba9ea

Please sign in to comment.