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

supporting fill-extrusion #211

Merged
merged 15 commits into from
Dec 9, 2023
Merged

supporting fill-extrusion #211

merged 15 commits into from
Dec 9, 2023

Conversation

krupupakku
Copy link
Contributor

Pull Request

Description

Hey! I needed to use extrusions in my project and I thought maybe you want to add support to them.

This is the result in example Layer page, adding controller.addFillExtrusionLayer:

@mariusvn
Copy link
Contributor

damn, did not expect that, would be a very nice improvent

@mariusvn
Copy link
Contributor

we need to wait until @m0nac0 gives you the approval for the ci process to run, then it will be reviewed and tested

@krupupakku
Copy link
Contributor Author

I saw it was running and the linter failed, I was looking for a log eheh

@mariusvn
Copy link
Contributor

to fix the formatting, we follow the official guidlines so just flutter format . in your root directory and it should do the trick.

For info, your latest ci report is here if i'm not wrong https://github.com/m0nac0/flutter-maplibre-gl/actions/runs/4429707859.

thanks for the work !

@mariusvn
Copy link
Contributor

I see you added a test for it on the example app, very nice too

@krupupakku
Copy link
Contributor Author

to fix the formatting, we follow the official guidlines so just flutter format . in your root directory and it should do the trick.

For info, your latest ci report is here if i'm not wrong https://github.com/m0nac0/flutter-maplibre-gl/actions/runs/4429707859.

thanks for the work !

Formatting done! thanks for the suggestion, it worked perfectly

@m0nac0
Copy link
Collaborator

m0nac0 commented Jul 6, 2023

@mariusvn Did you review and test this?

@krupupakku
Copy link
Contributor Author

Hey! how is it going? do you have some time to review this? I believe I need to update the branch as it has some conflicts now.. :P

lib/src/controller.dart Outdated Show resolved Hide resolved
@m0nac0
Copy link
Collaborator

m0nac0 commented Dec 4, 2023

Hey, sorry we missed your PR! If you can resolve the conflicts I'll be happy to review it. If you have trouble resolving the conflicts, let me know and I can take a look.

@krupupakku
Copy link
Contributor Author

Hey, sorry we missed your PR! If you can resolve the conflicts I'll be happy to review it. If you have trouble resolving the conflicts, let me know and I can take a look.

Ok I'll resolve conflicts today ;) Thanks a lot

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to confirm: were the modifications to this file, to ios/Classes/LayerPropertyConverter.swift and to lib/src/layer_properties.dart generated with the script?

Copy link
Contributor Author

@krupupakku krupupakku Dec 4, 2023

Choose a reason for hiding this comment

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

Hem... nope. which script? I added them manually.

EDIT: I didn't know anything about a script, and I didn't find any reference to it. if you tell me more, I can generate these modifications in the right way, sure :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oooh sorry I just reviewed it better and found it. scripts/lib/generate.dart
Let me check it better. back to you in a min

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I confirm you I added them manually. if you tell me how you run the generate.dart I will do the same way to be sure I keep consistency, instead of add them manually

Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to run the script with dart run .\scripts\lib\generate.dart.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems to add a few outdated comments though (referencing Mapbox instead of MapLibre)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this was a bit more complicated than I initially thought, I

  • made some fixes to the script's input style
  • added a README for the script
  • ran the script and checked the output
  • pushed those changes

I hope that's ok for you.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, the script wants to generate a parameter name of fill-extrusionLayer for the iOS code, which is invalid. I pushed a new commit that hopefully fixes that.

@m0nac0
Copy link
Collaborator

m0nac0 commented Dec 6, 2023

@krupupakku If you want to take a look at the changes from my 3 commits together (excluding whitespace changes), you can do that here https://github.com/maplibre/flutter-maplibre-gl/pull/211/files/ff22c991fb02ffb2dc986bd0c2ac6fe24d126dbe..a6f86eb6d7a3586e7088959867af2f04e6d07eb7?diff=unified&w=1

Let me know if that looks good from your side.

@krupupakku
Copy link
Contributor Author

krupupakku commented Dec 9, 2023

@krupupakku If you want to take a look at the changes from my 3 commits together (excluding whitespace changes), you can do that here https://github.com/maplibre/flutter-maplibre-gl/pull/211/files/ff22c991fb02ffb2dc986bd0c2ac6fe24d126dbe..a6f86eb6d7a3586e7088959867af2f04e6d07eb7?diff=unified&w=1

Let me know if that looks good from your side.

Oh marvellous! @m0nac0 thanks for taking care of if! LGTM!

@krupupakku
Copy link
Contributor Author

@krupupakku If you want to take a look at the changes from my 3 commits together (excluding whitespace changes), you can do that here https://github.com/maplibre/flutter-maplibre-gl/pull/211/files/ff22c991fb02ffb2dc986bd0c2ac6fe24d126dbe..a6f86eb6d7a3586e7088959867af2f04e6d07eb7?diff=unified&w=1
Let me know if that looks good from your side.

Oh marvellous! @m0nac0 thanks for taking care of if! LGTM!

@m0nac0 I also confirm you that the script now works (before it was giving me an error trying running it), and looks wonderful!

Copy link
Collaborator

@m0nac0 m0nac0 left a comment

Choose a reason for hiding this comment

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

Thank you again for you contribution!

@m0nac0 m0nac0 merged commit dc21739 into maplibre:main Dec 9, 2023
6 checks passed
@Robbendebiene
Copy link
Contributor

Robbendebiene commented Dec 11, 2023

Thanks for implementing this!
Unfortunately I get the following error (using Android emulator):


E/flutter ( 7457): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, null, null, java.lang.NullPointerException
E/flutter ( 7457): 	at com.mapbox.mapboxsdk.style.layers.Layer.nativeSetPaintProperty(Native Method)
E/flutter ( 7457): 	at com.mapbox.mapboxsdk.style.layers.Layer.setProperties(Layer.java:60)
E/flutter ( 7457): 	at com.mapbox.mapboxgl.MapboxMapController.addFillExtrusionLayer(MapboxMapController.java:524)
E/flutter ( 7457): 	at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:1090)
E/flutter ( 7457): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/flutter ( 7457): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter ( 7457): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/flutter ( 7457): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter ( 7457): 	at android.os.Handler.handleCallback(Handler.java:883)
E/flutter ( 7457): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/flutter ( 7457): 	at android.os.Looper.loop(Looper.java:214)
E/flutter ( 7457): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter ( 7457): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 7457): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter ( 7457): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/flutter ( 7457): )
E/flutter ( 7457): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter ( 7457): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter ( 7457): <asynchronous suspension>
E/flutter ( 7457): #2      MethodChannelMaplibreGl.addFillExtrusionLayer (package:maplibre_gl_platform_interface/src/method_channel_maplibre_gl.dart:709:5)
E/flutter ( 7457): <asynchronous suspension>
E/flutter ( 7457): #3      MaplibreMapController.addFillExtrusionLayer (package:maplibre_gl/src/controller.dart:520:5)
E/flutter ( 7457): <asynchronous suspension>
E/flutter ( 7457):

@krupupakku
Copy link
Contributor Author

Thanks for implementing this! Unfortunately I get the following error (using Android emulator):


E/flutter ( 7457): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, null, null, java.lang.NullPointerException
E/flutter ( 7457): 	at com.mapbox.mapboxsdk.style.layers.Layer.nativeSetPaintProperty(Native Method)
E/flutter ( 7457): 	at com.mapbox.mapboxsdk.style.layers.Layer.setProperties(Layer.java:60)
E/flutter ( 7457): 	at com.mapbox.mapboxgl.MapboxMapController.addFillExtrusionLayer(MapboxMapController.java:524)
E/flutter ( 7457): 	at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:1090)
E/flutter ( 7457): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/flutter ( 7457): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter ( 7457): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/flutter ( 7457): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter ( 7457): 	at android.os.Handler.handleCallback(Handler.java:883)
E/flutter ( 7457): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/flutter ( 7457): 	at android.os.Looper.loop(Looper.java:214)
E/flutter ( 7457): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter ( 7457): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 7457): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter ( 7457): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/flutter ( 7457): )
E/flutter ( 7457): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter ( 7457): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter ( 7457): <asynchronous suspension>
E/flutter ( 7457): #2      MethodChannelMaplibreGl.addFillExtrusionLayer (package:maplibre_gl_platform_interface/src/method_channel_maplibre_gl.dart:709:5)
E/flutter ( 7457): <asynchronous suspension>
E/flutter ( 7457): #3      MaplibreMapController.addFillExtrusionLayer (package:maplibre_gl/src/controller.dart:520:5)
E/flutter ( 7457): <asynchronous suspension>
E/flutter ( 7457):

🤔 super strange, I'm using it in my project and it's working in both android and iOS (i tried in simulator and physical device).

@m0nac0
Copy link
Collaborator

m0nac0 commented Dec 11, 2023

@Robbendebiene Could you share your Flutter code for adding the fill extrusion layer?

@Robbendebiene
Copy link
Contributor

I'm sorry for the confusion.

For testing I just copied a style that worked when loaded through URL without checking whether it uses the old or new (expression) syntax.

Changing this:

'fill-extrusion-base': {
  'type':'identity',
  'property':'render_min_height'
},

to

'fill-extrusion-base': ['get', 'render_min_height'],

solves the problem.

One thing I noticed when trying to create a minimal reproducible example is that the addLayer method doesn't forward the filter property for FillExtrusionLayerProperties:

addFillExtrusionLayer(sourceId, layerId, properties,
belowLayerId: belowLayerId,
sourceLayer: sourceLayer,
minzoom: minzoom,
maxzoom: maxzoom);

@m0nac0
Copy link
Collaborator

m0nac0 commented Dec 14, 2023

One thing I noticed when trying to create a minimal reproducible example is that the addLayer method doesn't forward the filter property for FillExtrusionLayerProperties:

Good catch! @krupupakku Was that intentional? If not, no worries, we can open an issue to add that.

@krupupakku
Copy link
Contributor Author

One thing I noticed when trying to create a minimal reproducible example is that the addLayer method doesn't forward the filter property for FillExtrusionLayerProperties:

Good catch! @krupupakku Was that intentional? If not, no worries, we can open an issue to add that.

Nope, must me an error from my side :P but it's very strange because I'm using filter in my project and it's working ahah

@m0nac0 let's open an issue as you said, I can take a better look later today or tomorrow ;) Thanks for noticing! @Robbendebiene

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 this pull request may close these issues.

None yet

6 participants