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

Line pattern cannot be un-set #22

Open
fynngodau opened this issue Mar 14, 2023 · 1 comment
Open

Line pattern cannot be un-set #22

fynngodau opened this issue Mar 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@fynngodau
Copy link
Collaborator

fynngodau commented Mar 14, 2023

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<LineString> {
    * @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
@fynngodau fynngodau added the bug Something isn't working label Mar 14, 2023
@fynngodau
Copy link
Collaborator Author

My current suspicion is that once line pattern property is set, annotationManager.enableDataDrivenProperty(LineOptions.PROPERTY_LINE_PATTERN) is called, causing layer.setProperties(linePattern(get(LineOptions.PROPERTY_LINE_PATTERN))) to be called, causing every line in the layer to expect a pattern. Hmm… I don't see a simple solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant