Open T-moz opened 5 months ago
A spontaneous idea (not saying this is necessarily better, but might be simpler): could we just expose an ("advanced") variant of the method that accepts a pre-encoded string, such that library consumers can decide how they want to do the json encode (e.g. on another isolate)
A spontaneous idea (not saying this is necessarily better, but might be simpler): could we just expose an ("advanced") variant of the method that accepts a pre-encoded string, such that library consumers can decide how they want to do the json encode (e.g. on another isolate)
Yes this would also work, and I don't see any performances differences between the two solutions. I think the direction we have to choose is how do you want the FlutterMaplibre API to be design.
updateLine
and updatesLines
).setFeatures
that accept an encoded string, and the package's user is responsible for the encoding).My point of view, is that the package maplibre_gl
should be a "deep module". Which means that the API exposed should not be very wide, and should handle most of the complexity.
Should it be a large API, with many optimised and specialised methods ? (like updateLine and updatesLines).
I even think that updateLine
can be remove and replace by updateLines
.
Package's users could still update one line, and they would be encourage to batch updates.
The same goes for other methods.
@m0nac0 I'm staring to think that your idea is better.
Because jsonEncode
takes time, but decoding a polyline string, then adapting to latlng
, and then converting to geojson
also takes a lot of time.
Package user that display list of complexe polylines, should be able to do all that with one compute. And for that, the package needs to expose a lowLevel method, that accept encodedGeoJson.
I will try to expose a method addEncodedGeoJsonSource
🤞
Before sending geojsonFeature through the method channel, the data is encode. Ex:![Untitled-8](https://github.com/maplibre/flutter-maplibre-gl/assets/28344195/187cde77-fc8b-4fc3-b7ff-5f270d884e4f)
the function
jsonEncode
is synchronous, and if the is a lot of data, like a line of 40k points, the main isolate can be blocked.This can lead to a UI freezed of n-seconds on the Flutter side.
See FlameChart: