-
Notifications
You must be signed in to change notification settings - Fork 12
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
Edit foci boundary enhancements #339
Changes from 4 commits
00c417e
63a4234
79c57a9
2edc61f
cc9ad5d
9ca58e1
091753e
c9eb7b6
9a42be5
08561cd
149d623
c017036
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import io.ona.kujaku.listeners.BoundsChangeListener; | ||
import io.ona.kujaku.listeners.LocationClientStartedCallback; | ||
import io.ona.kujaku.listeners.OnFeatureClickListener; | ||
import io.ona.kujaku.listeners.OnFeatureLongClickListener; | ||
import io.ona.kujaku.listeners.TrackingServiceListener; | ||
import io.ona.kujaku.location.KujakuLocation; | ||
import io.ona.kujaku.services.configurations.TrackingServiceUIConfiguration; | ||
|
@@ -188,6 +189,25 @@ public interface IKujakuMapView extends IKujakuMapViewLowLevel { | |
*/ | ||
void setOnFeatureClickListener(@NonNull OnFeatureClickListener onFeatureClickListener, @Nullable Expression expressionFilter, @Nullable String... layerIds); | ||
|
||
/** | ||
* Sets an {@link OnFeatureClickListener} which will be fired when a feature on the map in either of the {@code layerIds} | ||
* is long touched/clicked | ||
* | ||
* @param onFeatureLongClickListener | ||
* @param layerIds | ||
*/ | ||
void setOnFeatureLongClickListener(@NonNull OnFeatureLongClickListener onFeatureLongClickListener, @Nullable String... layerIds); | ||
|
||
/** | ||
* Sets an {@link OnFeatureClickListener} which will be fired when a feature on the map in either of the {@code layerIds} | ||
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. Change documentation here to link to OnFeatureLongClickListener |
||
* is long touched/clicked and/or fulfilling the filter defined in {@code filter} | ||
* | ||
* @param onFeatureLongClickListener | ||
* @param expressionFilter | ||
* @param layerIds | ||
*/ | ||
void setOnFeatureLongClickListener(@NonNull OnFeatureLongClickListener onFeatureLongClickListener, @Nullable Expression expressionFilter, @Nullable String... layerIds); | ||
|
||
/** | ||
* Checks if the map warms GPS(this just means the location service that is going to be used). | ||
* Warming the GPS in this case means that it starts the location services as soon as you open | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.ona.kujaku.listeners; | ||
|
||
import com.mapbox.geojson.Feature; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Richard Kareko on 5/18/20. | ||
*/ | ||
|
||
public interface OnFeatureLongClickListener { | ||
|
||
/** | ||
* Called when a features(s) is long clicked on the map and adheres to params passed in | ||
* {@link io.ona.kujaku.views.KujakuMapView#setOnFeatureClickListener(OnFeatureClickListener, String...)} | ||
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. Change documentation here to link to setOnFeatureLongClickListener |
||
* or {@link io.ona.kujaku.views.KujakuMapView#setOnFeatureClickListener(OnFeatureClickListener, com.mapbox.mapboxsdk.style.expressions.Expression, String...)} | ||
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. Change documentation here to link to setOnFeatureLongClickListener |
||
* | ||
* @param features | ||
*/ | ||
void onFeatureLongClick(List<Feature> features); | ||
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. Annotate |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import com.mapbox.geojson.Feature; | ||
import com.mapbox.geojson.FeatureCollection; | ||
import com.mapbox.geojson.Geometry; | ||
import com.mapbox.geojson.MultiPolygon; | ||
import com.mapbox.geojson.Point; | ||
import com.mapbox.geojson.Polygon; | ||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
|
@@ -217,6 +218,16 @@ public boolean startDrawing(@Nullable FillBoundaryLayer fillBoundaryLayer) { | |
List<Point> points = polygon.coordinates().get(0); | ||
this.startDrawingPoints(points); | ||
return true; | ||
} else if (geometry instanceof MultiPolygon) { | ||
// hide layer | ||
fillBoundaryLayer.disableLayerOnMap(mapboxMap); | ||
|
||
MultiPolygon multiPolygon = (MultiPolygon) geometry; | ||
for (List<List<Point>> polygonCoordinates : multiPolygon.coordinates()) { | ||
List<Point> points = polygonCoordinates.get(0); | ||
this.startDrawingPoints(points); | ||
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. Can you add an issue to improve this later? A multipolygon contains holes or can show a feature that is made of of multiple scattered polygons. In case you want to edit the boundary of Mombasa which is part of the Kenya boundary 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. Here is the link #340 |
||
} | ||
return true; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ | |
import io.ona.kujaku.listeners.BoundsChangeListener; | ||
import io.ona.kujaku.listeners.LocationClientStartedCallback; | ||
import io.ona.kujaku.listeners.OnFeatureClickListener; | ||
import io.ona.kujaku.listeners.OnFeatureLongClickListener; | ||
import io.ona.kujaku.listeners.OnKujakuLayerClickListener; | ||
import io.ona.kujaku.listeners.OnKujakuLayerLongClickListener; | ||
import io.ona.kujaku.listeners.OnLocationChanged; | ||
|
@@ -164,6 +165,7 @@ public class KujakuMapView extends MapView implements IKujakuMapView, MapboxMap. | |
private BoundsChangeListener boundsChangeListener; | ||
|
||
private OnFeatureClickListener onFeatureClickListener; | ||
private OnFeatureLongClickListener onFeatureLongClickListener; | ||
private String[] featureClickLayerIdFilters; | ||
private Expression featureClickExpressionFilter; | ||
|
||
|
@@ -829,6 +831,18 @@ public void setOnFeatureClickListener(@NonNull OnFeatureClickListener onFeatureC | |
this.featureClickExpressionFilter = expressionFilter; | ||
} | ||
|
||
@Override | ||
public void setOnFeatureLongClickListener(@NonNull OnFeatureLongClickListener onFeatureLongClickListener, @Nullable String... layerIds) { | ||
this.setOnFeatureLongClickListener(onFeatureLongClickListener, null, layerIds); | ||
} | ||
|
||
@Override | ||
public void setOnFeatureLongClickListener(@NonNull OnFeatureLongClickListener onFeatureLongClickListener, @Nullable Expression expressionFilter, @Nullable String... layerIds) { | ||
this.onFeatureLongClickListener = onFeatureLongClickListener; | ||
this.featureClickLayerIdFilters = layerIds; | ||
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. Setting layerIds to |
||
this.featureClickExpressionFilter = expressionFilter; | ||
} | ||
|
||
/** | ||
* Set listener when pressing a KujakuLayer | ||
* | ||
|
@@ -1124,6 +1138,15 @@ public boolean onMapClick(@NonNull LatLng point) { | |
public boolean onMapLongClick(@NonNull LatLng point) { | ||
PointF pixel = mapboxMap.getProjection().toScreenLocation(point); | ||
|
||
if (onFeatureLongClickListener != null) { | ||
List<com.mapbox.geojson.Feature> features = mapboxMap.queryRenderedFeatures(pixel, featureClickExpressionFilter, featureClickLayerIdFilters); | ||
|
||
if (features.size() > 0) { | ||
onFeatureLongClickListener.onFeatureLongClick(features); | ||
} | ||
} | ||
|
||
|
||
if (onKujakuLayerLongClickListener != null) { | ||
KujakuLayer layer = KujakuLayer.getKujakuLayerSelected(pixel, kujakuLayers, mapboxMap); | ||
if (layer != null) { | ||
|
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.
Change documentation here to link to OnFeatureLongClickListener