You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When displaying the Windows map control with the IsUserShowing attribute set to True and adding a Pin, the user's location pin disappears from the map, and no longer shows.
Expected Behavior
When IsShowingUser attribute is set to True, I would expect the User's location Pin to still be showing after adding a Pin to the Map.
Steps To Reproduce
Open up the CommunityToolkit.Maui.Sample Solution
Modify line 18, in the MapsPinsPage.xaml to add IsShowingUser="True"
Compile and run the sample
When the map displays it should show a Pin with your location
- .NET MAUI CommunityToolkit: 8.0.1
- OS: Windows 11 Pro 24H2
- .NET MAUI: 8.0.14
Anything else?
In looking at the source MapHandler.Windows.cs line 112 adds the location via the CallJSMethod(handler.PlatformView, $"addLocationPin()) call.
When adding a Pin, it gets added to the collection of Pins.
When the map handler is refreshed, there is a call to MapPins(). The method MapPins() removes all the Pins, and then adds them back via the Pin collection.
I believe that the User's location is never added back. There are multiple ways to solve this, but I first wanted to see if you could reproduce this error.
The text was updated successfully, but these errors were encountered:
mikelor
changed the title
[BUG]
[BUG] Windows Map control no longer displays the User's Location Pin after adding a Pin to the Map when IsShowingUser is set to True
Apr 7, 2024
My initial thinking is to modify the script function removeAllPins in line 302 to the following:
function removeAllPins()
{
map.entities.clear();
if (locationPin != null )
{
map.entities.push(locationPin);
map.setView({
center: location
});
}
}
This would add back the locationPin to the map.entities collection if it was not null.
Since the locationPin is only set in the addLocationPin() function which is called from the MapIsShowingUser(IMapHandler handler, IMap map) method. The removeLocationPin() function sets the value of locationPin to null.
Setting the view via the 'setView()` function is debatable since it modifies the current view region. After thinking about this a bit, I would suggest not including it. The developer can always modify the view back to the location if they choose.
mikelor
added a commit
to mikelor/Maui
that referenced
this issue
Apr 7, 2024
…ter adding a Pin to the Map when IsShowingUser is set to True #1801 (#1817)
Implementing Fix for Issue #1807. Modify Windows Map Pins Page sample show user. Updated MapHandler.Windows RemoveAllPins() to add back user location if showing user.
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
When displaying the Windows map control with the IsUserShowing attribute set to True and adding a Pin, the user's location pin disappears from the map, and no longer shows.
Expected Behavior
When IsShowingUser attribute is set to True, I would expect the User's location Pin to still be showing after adding a Pin to the Map.
Steps To Reproduce
IsShowingUser="True"
Link to public reproduction project repository
https://github.com/CommunityToolkit/Maui/tree/main/samples/CommunityToolkit.Maui.Sample
Environment
Anything else?
In looking at the source MapHandler.Windows.cs line 112 adds the location via the
CallJSMethod(handler.PlatformView, $"addLocationPin())
call.When adding a Pin, it gets added to the collection of Pins.
When the map handler is refreshed, there is a call to
MapPins()
. The methodMapPins()
removes all the Pins, and then adds them back via the Pin collection.I believe that the User's location is never added back. There are multiple ways to solve this, but I first wanted to see if you could reproduce this error.
The text was updated successfully, but these errors were encountered: