Bug 42151

Summary: UWP Map VisibleRegion is calculated incorrectly
Product: Forms Reporter: Charles Petzold <charles.petzold>
Component: WindowsAssignee: Bugzilla <bugzilla>
Status: VERIFIED FIXED    
Severity: normal CC: andreas, denis.geometrics, jas, rui.marinho, sahou, v-jawasw
Priority: ---    
Version: 2.3.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Tags: AC Is this bug a regression?: ---
Last known good build:

Description Charles Petzold 2016-06-24 14:49:32 UTC
On the UWP and Windows Phone 8.1 platforms, the VisibleRegion property of the Map is being calculated incorrectly and results in latitude and longitude spans that are half the correct values.

The error is in https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Maps.UWP/MapRenderer.cs, lines 217 and 218. The current code is:

var latitudeDelta = Math.Abs(center.Latitude - boundingBox.NorthwestCorner.Latitude); 
var longitudeDelta = Math.Abs(center.Longitude - boundingBox.NorthwestCorner.Longitude); 

The correct code is:

var latitudeDelta = Math.Abs(boundingBox.SoutheastCorner.Latitude - boundingBox.NorthwestCorner.Latitude); 
var longitudeDelta = Math.Abs(boundingBox.SoutheastCorner.Longitude - boundingBox.NorthwestCorner.Longitude);

Alternatively, the current line 219

Element.VisibleRegion = new MapSpan(center, latitudeDelta, longitudeDelta);

can be changed to: 

Element.VisibleRegion = new MapSpan(center, 2* latitudeDelta, 2 * longitudeDelta);
Comment 1 Samantha Houts [MSFT] 2017-02-01 01:03:38 UTC
*** Bug 48375 has been marked as a duplicate of this bug. ***
Comment 2 Andreas 2017-02-14 20:19:37 UTC
So, confirmed and with a given fix for almost a year ago. Still not fixed...
Microsoft is really showing their last, valiant, UWP-developers respect. NOT.
Comment 3 Samantha Houts [MSFT] 2017-02-15 18:25:33 UTC
https://github.com/xamarin/Xamarin.Forms/pull/724
Comment 4 Rui Marinho 2017-03-07 10:48:19 UTC
Should be fixed on 2.3.5-pre1
Comment 5 Jacky Waswani 2017-07-14 09:13:12 UTC
Have verified the bug with latest forms build version 2.3.5.256-pre6.

Issue is seems to be fixed with latest build as well.

Now the fixed code is added in the forms samples & user is able to see the correct location on map.