This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Xamarin.Forms.Map CameraChanged event #7260
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # Xamarin.Forms.Maps.Android/MapRenderer.cs # Xamarin.Forms.Maps.iOS/MapRenderer.cs
@roubachof What's the status of this PR? Your last comment mentions that there is still work to be done. Is that still the case? Thanks! |
@samhouts It's fine for iOS and Android, but I would need some help of someone from the uwp team maybe to solve the uwp issues I met... Maybe I should split the uwp version out so you could merge the iOS and Android version? |
@roubachof That sounds like a good idea! Thanks! |
6982bd8
to
84ac565
Compare
@samhouts removed the UWP implementation. |
Hi, @samhouts what is the status about this merge? |
Hello. |
Hi, any chance to have some progress on this? |
Closing this as we won't be adding anything new to Forms. Adding a tag to put it on the list to look into this for .NET MAUI. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
a/maps 🌐
API-change
Heads-up to reviewers that this PR may contain an API change
p/Android
p/iOS 🍎
potential-maui-material
t/bug 🐛
t/enhancement ➕
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Added a "camera changed" event to be notified when the maps is moved or zoomed. With the proper
CameraChangedEventArgs
and theCamera
property, it allows developers to add customs overlays withSkiaSharp
, or even hide or show some controls while the map is changing.Issues Resolved
Collaterally fixes an issue on
Android
.MoveCamera
is made anIllegalStateException
will be thrownAPI Changes
Added:
event EventHandler<CameraChangedEventArgs> CameraChanged;
Camera Camera { get; }
Platforms Affected
UWPBehavioral/Visual Changes
None.
Before/After Screenshots
Not applicable.
Testing Procedure
I tested the 3 platforms with the RunAway! app:
https://github.com/roubachof/SkiaSharpnado/tree/xamarin-maps
in the SessionMap.xaml.cs (naming is bad :):
Then checked that I can indeed move and zoom the map and the overlay is updated accordingly.
Platforms specific comments
Core
I created a
Camera
class withZoom
andPosition
to represent the current view photo settings.For the
Camera
property, I wasn't sure how to propagate a change from the renderer to the core class for a read only property.I reproduced the same pattern that the
VisibleRegion
property.Android
I added some code in the
OnLayout
method to return if the map size is 0, since theMoveToRegion
call will fail if it's the case.iOS
MkMapView
has noZoom
property, so I had to implement its own zoom.UWPThe zoom given by theMapControl
is not consistent with theGoogle Maps
andiOS
custom zooms. To have the same behavior as the others platforms, I had to compute it manually (it uses the same code as the iOS one).I added aOnSizeChanged
delegate for the initial Camera assignement. It fixes also a scenario when MoveToRegion is called before the layout pass is made, and then the region set by the user is not taken into account.Issues to solve on UWP before mergeThe zoom computation on uwp seems to be a little unaccurate, I don't really understand why. I would need a Bing maps expert for this :)TheActualCameraChanging
event seems to be aggressively invoked and seems to take a lot of UI thread time. I tried numerous tactics without much success... It works but it is a bit laggy in my sharpnado example.PR Checklist