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

Having Lines + GeoJson, lines are often broken #963

Closed
AAverin opened this issue Mar 23, 2022 · 14 comments · Fixed by #972
Closed

Having Lines + GeoJson, lines are often broken #963

AAverin opened this issue Mar 23, 2022 · 14 comments · Fixed by #972

Comments

@AAverin
Copy link
Contributor

AAverin commented Mar 23, 2022

I have 2 different layers, one for GeoJson, another for Lines with a LineController.
Lines often do not display correctly in that case.

@felix-ht
Copy link
Collaborator

Can you post a screenshot / more details how this goes wrong?

This is quite surprising to me as I use multiple line layers all the time an have yet to see an issue.

@AAverin
Copy link
Contributor Author

AAverin commented Mar 24, 2022

I am showing 4 lines of different color and often only one line is displayed. I first noticed it on release build on Android, everything seemed fine in debug. on iOS the issue was also present in debug.
The of adding lines code is working working because I use it on another screen without GeoJSON and with an option to move lines – no issues there.

@felix-ht
Copy link
Collaborator

What is strange that the annotation manager only wraps the geojson source /vector layer api.

The only thing i could think of is some overlap issue. Any vector layers you add later gets added over the annotations.

@AAverin
Copy link
Contributor Author

AAverin commented Mar 25, 2022

@felix-ht I did some more debugging.
Problem I see is on iOS and when I have 2 lines that I update depending on some state.
One line seems to update correctly, but having 2 lines, second line is just blinking and not updating correctly.

Only last call to await mapController.updateLine() works correctly.

I don't see this happening on Android, both lines update

@felix-ht
Copy link
Collaborator

can you post the code causing the issue?

@AAverin
Copy link
Contributor Author

AAverin commented Mar 25, 2022

I will try to reproduce on the sample app somehow.
In general, I am just drawing some lines on the map and allow two of them to be moved when user changes time slider position. When moving, I am updating the line using updateLine.

@felix-ht
Copy link
Collaborator

can you try putting some delay between those call to make sure that it's not a race condition?

@felix-ht
Copy link
Collaborator

can you check this branch? #970

@AAverin
Copy link
Contributor Author

AAverin commented Mar 25, 2022

@felix-ht still somewhat the same. I can see both lines updating, but one is blinking strangely all the time

@felix-ht
Copy link
Collaborator

does it keep blinking afterwards? does the update go through?

@AAverin
Copy link
Contributor Author

AAverin commented Mar 25, 2022

You can see a dark blue line on the left, above orange – this one is drawn wrong for some reason.
The light yellow and this dark blue are supposed to move both.
When moving the slider, you can see that dark blue is blinking and moving, but then quickly disapperas.
It is as if controller state is restored to the state where line is not moved.

RPReplay_Final1648217214.MP4

@felix-ht
Copy link
Collaborator

felix-ht commented Mar 25, 2022

you can try adding some debug code to setFeature in swift as well flutter - with this you should be able to see what goes on.

also set feature does not handle errors at all - so it might be a good idea to add some code there as well.

@felix-ht
Copy link
Collaborator

diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift
index 6aff92a..b866948 100644
--- a/ios/Classes/MapboxMapController.swift
+++ b/ios/Classes/MapboxMapController.swift
@@ -1312,6 +1312,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
     }
 
     func setFeature(sourceId: String, geojsonFeature: String) {
+        print("setFeature")
         do {
             let newShape = try MGLShape(
                 data: geojsonFeature.data(using: .utf8)!,
@@ -1321,6 +1322,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
                let shape = addedShapesByLayer[sourceId] as? MGLShapeCollectionFeature,
                let feature = newShape as? MGLShape & MGLFeature
             {
+                print(feature)
                 if let index = shape.shapes
                     .firstIndex(where: {
                         if let id = $0.identifier as? String,
@@ -1335,12 +1337,16 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
                 {
                     var shapes = shape.shapes
                     shapes[index] = feature
-
+                    print(index)
                     source.shape = MGLShapeCollectionFeature(shapes: shapes)
                 }
             }
 
-        } catch {}
+        } catch {
+            print("setFeature error")
+        }
+        print("setFeature done")
+
     }
 
     /*

@AAverin
Copy link
Contributor Author

AAverin commented Mar 25, 2022

@felix-ht I made a PR that seems to fix the issue for me. I will remove the logs now quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants