Reputation: 3889
I need to execute some code when the user finishes to zoom in/out the map. Its ZoomLevelChanged
event is raised as the user zooms in or out, so it is not a solution for me (mainly because the code i want to execute is a pretty expensive operation). Any ideas?
Upvotes: 0
Views: 399
Reputation: 355
I believe a better solution is to listen to the LoadingStatusChanged event, then take action when you get back MapLoadingStatus.Loaded.
public void LoadingStatusChangedEventHandler(MapControl sender, Object o)
{
if (sender.LoadingStatus == MapLoadingStatus.Loaded)
{
// The map has stopped moving and finished rendering
// If necessary, check that zoom level is different
DoExpensiveOperation();
}
}
I know the documentation for that event isn't great, but there's a little more information at this code sample, and you may be able to find even more on the git repo.
Good luck!!
Upvotes: 0
Reputation:
If the performance is the main issue here, you can "rerender" your map elements only when the zoom level changes from one integer to another (1->2, 2->3 and so on) (skiping the part after coma). As far as I know the maximum value for ZoomLevel
is 20 (for 2D
) mode. So I think it must be smooth enough for the user not to notice.
Some code:
public int ZoomLevel {get; set;} = initialZoomLevel;
private void OnZoomLevelChanged(object sender, EventArgs args)
{
if((int)Map.ZoomLevel!=ZoomLevel)
{
//Rerender stuff
}
}
Upvotes: 2