summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38284.cs
blob: f476e56390af795241dd79b29521778efa10e62a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Maps;


namespace Xamarin.Forms.Controls
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 38284, "when creating a map in iOS, if the map is not visible when the page is created the zoom level is offn")]
	public class Bugzilla38284 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		Map map1;
		Map map2;
		double Latitude = 28.032005;
		double Longitude = -81.948931;
		string LocationTitle = "Someplace Cool";
		string StreetAddress = "";

		protected override void Init()
		{
			var stack = new StackLayout();

			map1 = new Maps.Map
			{
				IsShowingUser = false,
				WidthRequest = 320,
				HeightRequest = 200
			};

			map2 = new Maps.Map
			{
				IsShowingUser = false,
				WidthRequest = 320,
				HeightRequest = 200
			};


			var btn = new Button { Text = "Show" };
			btn.Clicked += (sender, e) =>
			{
				map2.IsVisible = !map2.IsVisible;
			};

			stack.Children.Add(map1);
			stack.Children.Add(map2);
			stack.Children.Add(btn);
			DisplayMaps();
			Content = stack;
		}

		public void DisplayMaps()
		{
			map2.IsVisible = false;
			var mapPinPosition = new Position(Latitude, Longitude);

			var type = MapType.Satellite;
			map1.MapType = type;
			map2.MapType = type;
			var pin = new Pin
			{
				Type = PinType.Place,
				Position = mapPinPosition,
				Label = LocationTitle,
				Address = StreetAddress
			};
			map1.Pins.Add(pin);
			map2.Pins.Add(pin);

			// Move the map to center on the map location with the proper zoom level
			var lldegrees = 360 / (Math.Pow(2, 16));
			map1.MoveToRegion(new MapSpan(map1.Pins[0].Position, lldegrees, lldegrees));
			map2.MoveToRegion(new MapSpan(map2.Pins[0].Position, lldegrees, lldegrees));
		}
	}
}