Bug 48375 - Xamarin Forms Map: Wrong map dimension computation in UpdateVisibleRegion
Summary: Xamarin Forms Map: Wrong map dimension computation in UpdateVisibleRegion
Status: RESOLVED DUPLICATE of bug 42151
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-30 03:13 UTC by denis.geometrics
Modified: 2017-02-01 01:03 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 42151

Description denis.geometrics 2016-11-30 03:13:51 UTC
Xamarin Forms Map:
Bug only in UWP (Android and IOS are OK) in the class MapRenderer  method UpdateVisibleRegion

It is impossible to fix at any other level because method UpdateVisibleRegion is private.
It is called every time ZoomLevelChanged or CenterChanged is called.
Control.ZoomLevelChanged += async (s, a) => await UpdateVisibleRegion();
Control.CenterChanged += async(s, a) => await UpdateVisibleRegion();
It is also impossible to change Element.VisibleRegion because it is mot public

In UpdateVisibleRegion you  are only computing half the width of the map.
You have:
        var latitudeDelta = Math.Abs(center.Latitude - boundingBox.NorthwestCorner.Latitude);
        var longitudeDelta = Math.Abs(center.Longitude - boundingBox.NorthwestCorner.Longitude);
        Element.VisibleRegion = new MapSpan(center, latitudeDelta, longitudeDelta);
        
and should have:
 
 var latitudeDelta = Math.Abs(boundingBox.NorthwestCorner.Latitude - boundingBox.SoutheastCorner.Latitude);
 var longitudeDelta = Math.Abs(boundingBox.SoutheastCorner.Longitude - boundingBox.NorthwestCorner.Longitude);
 Element.VisibleRegion = new MapSpan(center, latitudeDelta, longitudeDelta);


In addition any call to MapSpan.FromCenterAndRadius or creating any MapSpan with more than 90 degree delta longitude is wrong and will cause the map to reset to smaller dimension. 
Without calling any MapSpan method you can zoom in the map from -180 to +180 longitude but as soon as you call any MapSpan methods the map displayed will be drawned to smaller size.
Comment 1 Samantha Houts [MSFT] 2017-02-01 01:03:38 UTC

*** This bug has been marked as a duplicate of bug 42151 ***