Bug 42151 - UWP Map VisibleRegion is calculated incorrectly
Summary: UWP Map VisibleRegion is calculated incorrectly
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows (show other bugs)
Version: 2.3.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
: 48375 (view as bug list)
Depends on:
Reported: 2016-06-24 14:49 UTC by Charles Petzold
Modified: 2017-07-14 09:13 UTC (History)
6 users (show)

See Also:
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
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

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.

Note You need to log in before you can comment on or make changes to this bug.