Skip to content

Navigator.CenterOn() does not refresh map until a mouse event happens #2778

Open
@mikernet

Description

Mapsui Version
5.0.0-beta.4

Mapsui Platform
WinUI / Uno.WinUI

Device
Windows 11, Android

Describe the bug
Navigate.CenterOn(x,y) has no effect (regardless of whether it is called in the Loaded event or well after the control has already loaded) until you move the mouse over the map on desktop or touch it on mobile, at which point it updates:

Screen_Recording_20241028_125624_Volt.mp4

I tried everything I could think of to get the view to update after calling CenterOn(), to no avail. This is the closest I got:

var navigator = MapView.Map.Navigator;

var (x, y) = SphericalMercator.FromLonLat(Model.Location.Longitude, Model.Location.Latitude);
navigator.CenterOn(x, y);

// This half works - the view refreshes but the tiles don't update, so if they aren't already cached
// you get a blank, or if only lower resolution is cached then it stays lower resolution until mouse
// is moved over map or map is touched.
LocationMap.Refresh();
LocationMap.RefreshData();
LocationMap.RefreshGraphics();

Expected behavior
The map should update when the method is called.

Screenshots
If applicable, add screenshots to help explain your problem.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions