maplibre / maplibre/maplibre-plugins-android

Line pattern cannot be un-set

Open
#22 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
50
Forks
33
PR merge metrics
No merged PRs in 30d

Description

After a line pattern is set, it cannot be un-set anymore to get back the default stroke (i.e. a colorful line).

I made a demo inside the sample app in https://github.com/e-foundation/maplibre-plugins-android/tree/demo-line-pattern (based on https://github.com/louwers/maplibre-plugins-android/tree/update-repo). To reproduce:

1. Compile
2. Open Change Line demo
3. In the overflow menu, select Toggle Pattern. Now a pattern is shown on the line.
4. Select Toggle Pattern again. The pattern is not shown anymore, but at the same time, the entire line becomes invisible (even though you'd expect it to be back to its previous state, since `setLinePattern(null)` was called).

(There's also some unrelated crashes in there.)

I thought that this diff would fix it, but it doesn't have any effect:

```
diff --git a/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Line.java b/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Line.java
index c4cac02..3f47e5a 100644
--- a/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Line.java
+++ b/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Line.java
@@ -343,7 +343,11 @@ public class Line extends Annotation {
* @param value constant property value for String
*/
public void setLinePattern(String value) {
- jsonObject.addProperty(LineOptions.PROPERTY_LINE_PATTERN, value);
+ if (value != null) {
+ jsonObject.addProperty(LineOptions.PROPERTY_LINE_PATTERN, value);
+ } else {
+ jsonObject.remove(LineOptions.PROPERTY_LINE_PATTERN);
+ }
}

@Override
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Toggle Pattern behavior in the sample app's Change Line demo, then inspect plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/Line.java, especially setLinePattern. Compare the serialized line properties before and after setLinePattern(null); done means toggling the pattern restores the prior colorful line instead of making it invisible.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.