Skip to content
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -396,25 +396,29 @@ public void onMapLongClick(LatLng latLng) {

@Override
public boolean onMarkerClick(Marker marker) {
Comment thread
seadowg marked this conversation as resolved.
if (featureClickListener != null) { // FormMapActivity
featureClickListener.onFeature(findFeature(marker));
} else { // GeoWidget
onMapClick(marker.getPosition());
MarkerFeature markerFeature = getFeature(marker);
if (markerFeature != null) {
if (featureClickListener != null && markerFeature.isClickable()) {
featureClickListener.onFeature(getFeatureId(marker));
} else {
onMapClick(marker.getPosition());
}
}

return true; // consume the event (no default zoom and popup behaviour)
}

@Override
public void onPolylineClick(Polyline polyline) {
if (featureClickListener != null) {
featureClickListener.onFeature(findFeature(polyline));
featureClickListener.onFeature(getFeatureId(polyline));
}
}

@Override
public void onPolygonClick(@NonNull Polygon polygon) {
if (featureClickListener != null) {
featureClickListener.onFeature(findFeature(polygon));
featureClickListener.onFeature(getFeatureId(polygon));
}
}

Expand All @@ -423,7 +427,7 @@ public void onMarkerDragStart(Marker marker) {
// When dragging starts, GoogleMap makes the marker jump up to move it
// out from under the user's finger; whenever a marker moves, we have
// to update its corresponding feature.
updateFeature(findFeature(marker));
updateFeature(getFeatureId(marker));
}

@Override
Expand All @@ -432,12 +436,12 @@ public void onMarkerDrag(Marker marker) {
// obtained from a GPS reading, so the altitude and standard deviation
// fields are no longer meaningful; reset them to zero.
marker.setSnippet("0;0");
updateFeature(findFeature(marker));
updateFeature(getFeatureId(marker));
}

@Override
public void onMarkerDragEnd(Marker marker) {
int featureId = findFeature(marker);
int featureId = getFeatureId(marker);
updateFeature(featureId);
if (dragEndListener != null && featureId != -1) {
dragEndListener.onFeature(featureId);
Expand Down Expand Up @@ -528,22 +532,34 @@ private void moveOrAnimateCamera(CameraUpdate movement, boolean animate) {
}
}

@Nullable
private MarkerFeature getFeature(Marker marker) {
for (int featureId : features.keySet()) {
if (features.get(featureId).ownsMarker(marker)) {
return (MarkerFeature) features.get(featureId);
Comment thread
seadowg marked this conversation as resolved.
Outdated
}
}

return null;
}

/**
* Finds the feature to which the given marker belongs.
* Finds the feature ID to which the given marker belongs.
*/
private int findFeature(Marker marker) {
private int getFeatureId(Marker marker) {
for (int featureId : features.keySet()) {
if (features.get(featureId).ownsMarker(marker)) {
return featureId;
}
}
return -1; // not found

return -1;
}

/**
* Finds the feature to which the given polyline belongs.
*/
private int findFeature(Polyline polyline) {
private int getFeatureId(Polyline polyline) {
for (int featureId : features.keySet()) {
if (features.get(featureId).ownsPolyline(polyline)) {
return featureId;
Expand All @@ -552,7 +568,7 @@ private int findFeature(Polyline polyline) {
return -1; // not found
}

private int findFeature(Polygon polygon) {
private int getFeatureId(Polygon polygon) {
for (int featureId : features.keySet()) {
if (features.get(featureId).ownsPolygon(polygon)) {
return featureId;
Expand Down Expand Up @@ -682,18 +698,29 @@ public interface MapFeature {
}

private static class MarkerFeature implements MapFeature {
private final MarkerDescription markerDescription;
private Marker marker;
private final Context context;

MarkerFeature(Context context, MarkerDescription markerDescription, GoogleMap map) {
this.context = context;
marker = createMarker(context, markerDescription, map);
this.markerDescription = markerDescription;
marker = createMarker(context, this.markerDescription, map);
}

public void setIcon(MarkerIconDescription markerIconDescription) {
marker.setIcon(getBitmapDescriptor(context, markerIconDescription));
}

public boolean isClickable() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be private.

@seadowg seadowg Jul 21, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to leave it private like the other methods on this class. The outer class can access it because Java (if it was Kotlin we'd have a file private class instead), but it makes more sense to have the inner class be private to the outer class and then have the methods used by things outside the inner class be public.

MarkerIconDescription iconDescription = markerDescription.getIconDescription();
if (iconDescription instanceof MarkerIconDescription.TracePoint) {
Comment thread
seadowg marked this conversation as resolved.
Outdated
return false;
} else {
return ((MarkerIconDescription.DrawableResource) iconDescription).getClickable();
}
}

public MapPoint getPoint() {
return fromMarker(marker);
}
Expand Down