Maui
Maui copied to clipboard
[Proposal] Windows Map handler based on WebView
Windows Map handler
- [x] Proposed
- [x] Prototype: Started
- [x] Implementation: Started
- [ ] iOS Support
- [ ] Android Support
- [ ] macOS Support
- [x] Windows Support
- [ ] Unit Tests: Not Started
- [ ] Sample: Not Started
- [ ] Documentation: Not Started
Link to Discussion
Summary
We have released the Map view on MAUI .net7, unfortunately there was no Windows handler since WinUI doesn't have a MapControl yet, this proposal closes the gap on Windows by providing a Map handler based on WebView and the Bing Maps SDK. This was discussed internally on the .NET MAUI team, and decided to provide this on the Toolkit and to on MAUI itself.
Motivation
Enabling users to have a cross platform implementation of Maps
Detailed Design
Using a WebView2 control to load a local HTML page that renders the Bing Maps control, and add javascript interop to map MAUI Map properties to the Web Bing maps control.
Usage Syntax
XAML Usage
None
C# Usage
MauiApp.CreateBuilder().UseMauiCommunityToolkitMaps("key")
Drawbacks
The drawback is this will be removed in the future when WinUI team provides the MapControl.
Alternatives
Unresolved Questions
Thanks Rui! This appears to be windows-specific.
Should this be added to the Windows Community Toolkit? https://github.com/CommunityToolkit/WindowsCommunityToolkit
I don' think so .. this is more to help MAUI users and migration from Xamarin.Forms to MAUI.
Why it cannot be a separate package or a part of .NET MAUI? It may be confused for users in feature when the maps available in both .NET MAUI and Community Toolkit. Also Toolkit is based on initial .NET MAUI release (6.0.312). Do we want to upgrade?
@VladislavAntonyuk this would live in the Community Toolkit until we have a proper solution for WinUI , and then we would obsolete and drop it from the Community Toolkit. We talked internally and this was the best decision as we don't want to put it on MAUI repo for now. This would be shipped on the toolkit on a 7.0 version.
I'm just thinking loud. What about using OpenStreet map for Windows only. https://github.com/OsmSharp/core there is already an implementation for C# that I'm not sure it this could work on Windows, but it may worth it a try? This way maps are loaded natively and if a user wants something different then they can use an embedded webview for it.
I personally do not see value of creating a custom webview for maps since it does not show the same performance and will be limited by the web technologies instead of using device capabilities such as gyro, etc.
Just thinking loud! What do you all think?
Thanks for reading me :)
What performance issue? tbh I run the sample and I don't see any big performance issues compared with other platforms. Also the implementation uses device capabilities like gps to get user location etc. |
@jfversluis @brminnick can someone help me figure if this can go in our not? who makes the decision? if it can't be here I will publish this somewhere else.
Thanks
@rmarinho We'll review it in our next standup, on 06 October.
You're welcome to join us if you'd like (12pm PT), or feel free to do a data dump with @jfversluis + @kphillpotts and they can help guide the conversation on your behalf!
Supporting OpenStreetMap would be useful as a separate control. If you are using Blazor, then you can have the same map experience across the mobile, desktop, and web.
I'm just thinking loud. What about using OpenStreet map for Windows only. https://github.com/OsmSharp/core there is already an implementation for C# that I'm not sure it this could work on Windows, but it may worth it a try? This way maps are loaded natively and if a user wants something different then they can use an embedded webview for it.
Please have a look at #866 which apparently doesn't get tagged here automatically, as it's a discussion rather than an issue.
My point there being:
[this] is intended as a stopgap solution because MAUI doesn't support Windows yet with their map component. It has a https://github.com/CommunityToolkit/Maui/issues/605#issuecomment-1263653226 that a generic OSM map component would be useful, however I don't completely agree with that. I'd much rather have the option to switch MAUI's map control to a different tile/image source. That might be a community feature rather than a core MAUI feature though.
This would probably involve work on both sides. If MAUI has the correct level of separation of concerns and accessible layers of abstraction, the extra implementations can be part of the community toolkit.
I think there must be some separation between:
- Image/Tile source
- Projection
- Rendering
- Control
- Interaction