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

Full source support #797

Merged
merged 16 commits into from
Jan 13, 2022
Merged

Full source support #797

merged 16 commits into from
Jan 13, 2022

Conversation

felix-ht
Copy link
Collaborator

@felix-ht felix-ht commented Nov 30, 2021

I'm currently working on fully supporting all types of sources. Related to #758.
Doing this now because i started to look at adding raster layer and doing this without code gen seemed like a bad idea, so i might as well go all the way.

This includes supporting everything in the style spec with relation to sources

  • vector
  • raster
  • raster_dem
  • geojson
  • video
  • image

This will also add support for clustering, as this is part of the source spec. #752

Todo:

  • basic code gen for dart
    - [ ] better code gen for dart (required args - args that are not nullable)
  • web implementation
  • ios implementation
  • android implementation

This will take some to until it lands (as im not working full-time on this, but should be this year), but I wanted to add this early as a draft. Most of the code is subject to change. So feel free to take a look, but no need to review as of now.

@felix-ht felix-ht added enhancement New feature or request android ios web labels Nov 30, 2021
@felix-ht felix-ht had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:32 Failure
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:32 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:33 Inactive
@felix-ht felix-ht had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:33 Failure
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:35 Inactive
@felix-ht felix-ht had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:35 Failure
@felix-ht felix-ht marked this pull request as draft November 30, 2021 18:38
@felix-ht felix-ht had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:53 Failure
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN November 30, 2021 18:53 Inactive
@kamami
Copy link

kamami commented Dec 14, 2021

How's it going? Very interested in those features!

@felix-ht
Copy link
Collaborator Author

might be able to work on this next week - let's see

@kamami
Copy link

kamami commented Dec 16, 2021

That would be awesome!

@tobrun
Copy link
Collaborator

tobrun commented Dec 16, 2021

you are a gem @felix-ht, let me know if you want to divide the work, happy to help out

@felix-ht
Copy link
Collaborator Author

I added a working example for the web version - Various Sources. This currently shows geojson (with clustering) vector and raster sources.

@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 17:46 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 17:46 Inactive
@felix-ht
Copy link
Collaborator Author

So iOS Android and web are now able to show all sources, and working as expected.

One thing currently still missing is the option to add an image as raw bytes. This is not part of the normal style spec, and also not supported on web. So im not sure if i should even add it. Might be more elegant to rely on local - (file) uris to load assets? @tobrun

I will do some cleanup besides that and remove the draft status afterwards.

@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 18:29 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 18:29 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 18:33 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 18:34 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 18:47 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN January 10, 2022 18:47 Inactive
@felix-ht felix-ht marked this pull request as ready for review January 11, 2022 15:23
Copy link
Collaborator

@tobrun tobrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing work @felix-ht

@tobrun tobrun merged commit a484bc4 into master Jan 13, 2022
@tobrun tobrun deleted the sources branch January 13, 2022 15:54
@kamami
Copy link

kamami commented Jan 13, 2022

Great! Now we only need some proper examples and guides, on how to achieve e.g. clustering with this plugin :D

@felix-ht
Copy link
Collaborator Author

felix-ht commented Jan 13, 2022

@kamami there are pretty decent examples for all source types (and clustering) examples in example/lib/sources.dart

@laudaget
Copy link

laudaget commented Jan 24, 2022

@felix-ht I cant figure out how to style the none clustered points like in the example given for android:

https://docs.mapbox.com/ios/legacy/maps/examples/clustering/?q=attribution&size=n_10_n

Is there something similiar to predicates? Or am i missing something out? Thank you!

@felix-ht
Copy link
Collaborator Author

felix-ht commented Jan 24, 2022

@laudaget layers currently don't support filtering - so no. Please create a separate ticket for this tho.

@flutter-mapbox-gl flutter-mapbox-gl locked as off-topic and limited conversation to collaborators Jan 24, 2022
@AAverin
Copy link
Contributor

AAverin commented Feb 3, 2022

@felix-ht I am now exploring this new feature and implement clustering in my app.
Is there setSource similar to how we have setGeoJsonSource?
Or what is the workflow exactly?

I have tried removing the source because I have points changing for clustering when camera moves, but got an error Source 'spots' is in use, cannot remove and then PlatformException and crash with CannotAddSourceException: Source spots already exists when adding.

@AAverin
Copy link
Contributor

AAverin commented Feb 3, 2022

Removing all layers first helped, but probably setSource and keeping all the layers would be better. If I have added source like

 await _mapController?.addSource(
          "spots",
          GeojsonSourceProperties(
              data: vm!.spotsGeoJson,
              cluster: true,
              clusterMaxZoom: 14, // Max zoom to cluster points on
              clusterRadius:
                  50 // Radius of each cluster when clustering points (defaults to 50)
              ));

Is it safe then later to call setGeoJsonSource? Would it just update the data for the source in geojson format?
What about SourceOptions?

@felix-ht
Copy link
Collaborator Author

felix-ht commented Feb 3, 2022

Removing all layers first helped, but probably setSource and keeping all the layers would be better. If I have added source like

 await _mapController?.addSource(
          "spots",
          GeojsonSourceProperties(
              data: vm!.spotsGeoJson,
              cluster: true,
              clusterMaxZoom: 14, // Max zoom to cluster points on
              clusterRadius:
                  50 // Radius of each cluster when clustering points (defaults to 50)
              ));

Is it safe then later to call setGeoJsonSource? Would it just update the data for the source in geojson format? What about SourceOptions?

yes that should be save - as far as i know. I will only change the geojson data - the options should remain untouched.

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

Successfully merging this pull request may close these issues.

6 participants