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

Adjust Typings for Node Platform #871

Merged
merged 8 commits into from
Mar 10, 2023
Merged

Conversation

etnav
Copy link
Contributor

@etnav etnav commented Mar 2, 2023

Adjusted the existing typings and expanded it with some new functions.

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 3, 2023

@KiwiKilian , since you made the original typings PR #766, I was wondering what you think of these changes.

Layout wise this looks good to me I think. From the examples in sources code it seems like it makes sense to add these.

@louwers louwers added the node label Mar 3, 2023
@louwers
Copy link
Collaborator

louwers commented Mar 3, 2023

Thanks for your contribution! @etnav 🚀

Copy link
Contributor

@KiwiKilian KiwiKilian left a comment

Choose a reason for hiding this comment

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

Looks good! Just some small recommendations from my side.

I struggle to call these functions to validate if it works. For example, when to call setBearing, setPitch or setCenter? My best guess was to call between map.load and map.render, but I can't seem to make a difference in the rendered output image. Do you have an example/use case where those functions are used?

platform/node/index.d.ts Outdated Show resolved Hide resolved
platform/node/index.d.ts Outdated Show resolved Hide resolved
platform/node/index.d.ts Outdated Show resolved Hide resolved
platform/node/index.d.ts Outdated Show resolved Hide resolved
@KiwiKilian
Copy link
Contributor

KiwiKilian commented Mar 7, 2023

@etnav thanks for applying the improvements. Could you provide some usage example?

I struggle to call these functions to validate if it works. For example, when to call setBearing, setPitch or setCenter? My best guess was to call between map.load and map.render, but I can't seem to make a difference in the rendered output image. Do you have an example/use case where those functions are used?

If it helps, here is a minimal usage example repo: https://github.com/KiwiKilian/maplibre-gl-native-node-example/blob/main/index.ts

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 7, 2023

@etnav thanks for applying the improvements. Could you provide some usage example?

I struggle to call these functions to validate if it works. For example, when to call setBearing, setPitch or setCenter? My best guess was to call between map.load and map.render, but I can't seem to make a difference in the rendered output image. Do you have an example/use case where those functions are used?

If it helps, here is a minimal usage example repo: https://github.com/KiwiKilian/maplibre-gl-native-node-example/blob/main/index.ts

I was trying myself to see if I could get any of these functions to work with https://github.com/acalcutt/maplibre-node-test/blob/main/maplibre-node-test/app.js#L46-L47 , but I had no luck getting them to do anything there either.

Not sure I really get the need for some of these functions, wouldn't you have to call render, which has most of these map options (setBearing, setPitch or setCenter) already?
https://github.com/maplibre/maplibre-gl-native/tree/main/platform/node#rendering-a-map-tile

@etnav
Copy link
Contributor Author

etnav commented Mar 7, 2023

@etnav thanks for applying the improvements. Could you provide some usage example?

I struggle to call these functions to validate if it works. For example, when to call setBearing, setPitch or setCenter? My best guess was to call between map.load and map.render, but I can't seem to make a difference in the rendered output image. Do you have an example/use case where those functions are used?

If it helps, here is a minimal usage example repo: https://github.com/KiwiKilian/maplibre-gl-native-node-example/blob/main/index.ts

@KiwiKilian @acalcutt If it helps, I have only used map.setLayoutProperty(layerId, "visibility", "visible") to change a property of a specific layer, and that works. I figured that adding all of the functions would make sense also, but it seems that they do absolutely nothing indeed. Maybe someone with more knowledge could shed some light here?

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 7, 2023

I did a lot of searching trying to find any use of these funtions in node, but I only found iOS/Android/Python examples.

I'm not really a c++ programmer, but to me it looks like render (center, zoom, bearing pitch) always get set based on RenderOptions. However, when you call SetCenter/SetZoom it doesn't update RenderOptions, instead it tries to set the Camera directrly, which I think later gets overwitten by whats in RenderOptions when render runs.

Seems like it would be pretty simple to update RenderOptions when SetCenter/SetZoom gets called, kind of like how those options get updated when you supply options to render

EDIT: btw, I don't expect this to be solved in this PR, but I think it explains why these functions seem like they don't work. If these were used on a live view, I think setting camera position makes sense. In this node version I feel like you would always have to render to get anything out... am I wrong on this? If that's the case it seems like SetCenter/SetZoom/etc should set the render option values, so it shows what the user set.

@KiwiKilian
Copy link
Contributor

Seems like it would be pretty simple to update RenderOptions when SetCenter/SetZoom gets called, kind of like how those options get updated when you supply options to render

Question would be, what's the benefit of setting those render options another way?

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 8, 2023

I was talking to @tdcosta100 about this yesterday and he found a solution to make those functions work.

If I understand correctly, mbgl core has two methods for render. One version takes camera options, and the other takes no options. In the node version, only the render that takes camera options was implemented, so like I found this overwrites the view settings.

@tdcosta100 was able to implement the version of render that takes no options, With the second method available, you can call a render with no options, and it just renders whatever view is showing. This allows it to work with the additional functions we couldn't get to work here.

Right now you can see the changes he made here, but we should have a PR to discuss it more soon
main...tdcosta100:maplibre-gl-native:mbgl-node-enhancements

@etnav
Copy link
Contributor Author

etnav commented Mar 8, 2023

I was talking to @tdcosta100 about this yesterday and he found a solution to make those functions work.

If I understand correctly, mbgl core has two methods for render. One version takes camera options, and the other takes no options. In the node version, only the render that takes camera options was implemented, so like I found this overwrites the view settings.

@tdcosta100 was able to implement the version of render that takes no options, With the second method available, you can call a render with no options, and it just renders whatever view is showing. This allows it to work with the additional functions we couldn't get to work here.

Right now you can see the changes he made here, but we should have a PR to discuss it more soon main...tdcosta100:maplibre-gl-native:mbgl-node-enhancements

Sounds and looks good. Interesting to see what is actually going on in the background.

What do you think about the typings changes regarding this PR, do we wait for the new PR or implement only the working parts now?

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 8, 2023

What do you think about the typings changes regarding this PR, do we wait for the new PR or implement only the working parts now?

I think we should wait for the other PR, so all these functions can work when the typings are released. His changes also add SetSize, which would also be good to add typings for. But this also depends what people think of those changes (they seem pretty minimal to me)

@tdcosta100
Copy link
Contributor

PR #891 is alive, and if you accept my suggestion: I think all mapped methods can be enriched by their documentation here:

https://github.com/maplibre/maplibre-gl-native/blob/main/platform/node/src/node_map.cpp

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 9, 2023

I merged #891 . Could Typing for SetSize, and possibly a new one for render without the RenderOptions be added?

@etnav
Copy link
Contributor Author

etnav commented Mar 9, 2023

I merged #891 . Could Typing for SetSize, and possibly a new one for render without the RenderOptions be added?

Great, I added SetSize and render without RenderOptions. I tested it briefly on my end and it worked with both render calls. Would be great if someone could also test it.

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 9, 2023

I Tested here in Visual Studio 2022 Community and this all looks nice there

image
image
image
image
image
image

@acalcutt
Copy link
Collaborator

acalcutt commented Mar 9, 2023

Before this is merged, can you add a entry to the node changelog, under 5.2.0
https://github.com/maplibre/maplibre-gl-native/blob/main/platform/node/CHANGELOG.md

Once this is merged I will do another 5.2.0 pre-release so we can test this all together better.

@acalcutt acalcutt merged commit ad1722f into maplibre:main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants