josxha / flutter-maplibre

Permissive and performant mapping library that supports Mapbox Vector Tiles (MVT) powered by MapLibre SDKs.
https://flutter-maplibre.pages.dev
Other
17 stars 3 forks source link

[FEATURE] Introduce SVG symbol source support #38

Closed gabbopalma closed 2 weeks ago

gabbopalma commented 1 month ago

Feature Description

Currently SVG images are not supported for Symbol sources. I found that this integration was planned by MapLibre in its roadmap, but I don't actually know if it is supported in the native repositories for Android and iOS. If parsing this format is already supported by the natives, the integration in Flutter would be a big plus.

Describe alternatives you've considered

An alternative is to recognize the image format and then parse the SVGs as well, converting them to a PNG format. I think this can be avoided, but it can be a solution.

Additional context

https://maplibre.org/roadmap/svg-symbol-source/ https://github.com/maplibre/maplibre/issues/271

josxha commented 1 month ago

SVG support for MapLibre is currently listed under the "Under Consideration" section. MapLibre on Android for example expects a Bitmap to it's pretty save to say it's currently not supported. (: However, there is still some opportunity that would indirectly add support for SVGs as well. It would be amazing if it users would be possible to use widgets as symbols on the map. It is possible to rasterize a rendered widget to an image and pass it to the MapLIbre SDK. This will probably have a slight delay until the rasterized widget gets displayed on the MapLibre map but it could be acceptable for a lot of users when they can use a simple widget tree to design their symbols. A small example on how to turn a widget tree into an png image can be seen here: https://github.com/josxha/flutter-maplibre/blob/test/widget-to-png/example/lib/callbacks_page.dart

josxha commented 2 weeks ago

I added support for widget markers using the new WidgetLayer in the MapLibreMap(children: []) list. The solution is not perfect because there is a slight delay when moving the map around but it's a start. The delay will decrease once the merged platform and ui thread get shipped to the stable branch. Currently this is only done on the main branch.