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

Add editBoundaryMode on DrawingManager #349

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions library/src/main/java/io/ona/kujaku/manager/DrawingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class DrawingManager {
private boolean drawingEnabled;

private FillBoundaryLayer currentFillBoundaryLayer;
private boolean editBoundaryMode;

/**
* Constructor
Expand Down Expand Up @@ -110,18 +111,21 @@ public void onAnnotationDragFinished(Circle circle) {
mapboxMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
public boolean onMapClick(@NonNull LatLng point) {
final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, (Expression) null, CircleManager.ID_GEOJSON_LAYER);

if (features.size() == 0 && drawingEnabled) {
if (getCurrentKujakuCircle() != null) {
unsetCurrentCircleDraggable();
} else {
drawCircle(point);
}
if (!editBoundaryMode) {
final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, (Expression) null, CircleManager.ID_GEOJSON_LAYER);

if (onDrawingCircleClickListener != null) {
onDrawingCircleClickListener.onCircleNotClick(point);
if (features.size() == 0 && drawingEnabled) {
if (getCurrentKujakuCircle() != null) {
unsetCurrentCircleDraggable();
} else {
drawCircle(point);
}

if (onDrawingCircleClickListener != null) {
onDrawingCircleClickListener.onCircleNotClick(point);
}
}
}

Expand Down Expand Up @@ -234,6 +238,11 @@ public boolean startDrawing(@Nullable FillBoundaryLayer fillBoundaryLayer) {
return false;
}

public boolean editBoundary(@NonNull FillBoundaryLayer fillBoundaryLayer) {
editBoundaryMode = true;
return startDrawing(fillBoundaryLayer);
}

/**
* Start Drawing. A list of point can be passed to init the drawing.
*
Expand Down