-
Notifications
You must be signed in to change notification settings - Fork 501
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
Add support for (geojson) layers #723
Conversation
added dart template
minor cleanup
* fixed issue with ios and array literals * added belowId options to addLayer functions * added set setGeoJsonSource to set new data on the fly
Note that belowLayerId in addFill{Type} is currently ignored for the web version - this will be addressed with andrea689/mapbox-gl-dart#15 |
Man, tell me you didn't type every single of those 10k lines and managed to auto-generate all the boilerplate somehow! |
@felix-ht It would be great if we could also support the clustering attributes for geojson sources (https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson-cluster). That would finally enable clustering in this plugin, a quite frequently requested feature. But I totally understand if you don't want to add even more changes to this PR, we can also just open an issue for that after this PR has landed. |
@m0nac0 i took a look and adding clustering should be pretty straightforward after this. It's also useful for my own usecase. We would have to add some new code gen to create the ClusterProperties object, and parse it one the native side. This is trivial for web but certainly somewhat harder for native. However i would like to push this to a future PR so we can get this one merged sooner. The api would stay stable as we would simply add some named parameters to Another thing i want to add in the future is the ability to only update a specific feature in a source without replacing the whole collection. But i would also push this to some other future PR. On a side note: i finished integrating this PR/branch into my own code base - an everything seems to work fine across all platforms. (Including fairly complicated data driven styles) |
@felix-ht amazing work and also thanks for @maximumbuster for kicking this off. |
Thanks for this awesome support and work @felix-ht Question - you noted it worked across multiple platforms but I noticed the code for addGeoJsonSource throws an error for non web? Or does this work on iOS & Android too? https://github.com/flutter-mapbox-gl/maps/blob/master/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart#L280 Also, can a source be removed? I'm getting an error on rebuild when the data changes due to adding the same geojson source twice (it is already on the map). Should be an easy fix of checking if it is there first, but I get an error |
@lukemadera Regarding your first question: the implementation for iOS and Android lives in https://github.com/flutter-mapbox-gl/maps/blob/master/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart (it mostly just calls the relevant platform channel methods).
|
Thanks @m0nac0 ! I am using |
Sorry, I haven't used the new GeoJson sources myself. |
@lukemadera if you have issues please create a new ticket - this is not the place for discussions. But as far as i know removeSource should work fine. (You have to remove any layer attached to the source first) |
As noted above @felix-ht I get an error: |
you have to use the MapboxMapController not the MapboxMap |
* Cherry-picked: Add support for (geojson) layers (flutter-mapbox-gl/maps#723) * CI: also run pub get for scripts Co-authored-by: Felix Horvat <felix.horvat@ocell.aero> Co-authored-by: Max Buster <max@outway.io>
* Added source and layers * updates * Changes * added symbol layer to ios * example code gen with mustache * added swift and full java generation * cleaned generator code added dart template * improved generation * added doc string generation * added web bindings * working android implementation * working web version * basic working ios version * working ios version * added color tools * added layer_properties * fixed doc issue * added click support for ios, android, and web * getting access_token from env minor cleanup * fixed lint issues * removed access token changes * removed package config * code review changes * more code review changes * deprecated addLayer fixed issue with remove source * added colon to Sdk Support * removed token * renamed removeImageSource to removeSource * added missing result.sucess * fixed issue with onFillTapped and stacked layers * added setSource and add below layer capability * fixed issue with ios and array literals * added belowId options to addLayer functions * added set setGeoJsonSource to set new data on the fly * added doc strings * fixed issues with android in the example Co-authored-by: Max Buster <max@outway.io> (cherry picked from commit 3c0ae33)
Adding full support for feature layers for ios, android and web. Click detection for these layers are supported as well. Code generation takes care of creating most of the code. Thanks to @maximumbuster for getting this started
Limitations
Notes
This pull request is based on code from #272 & #326