summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
blob: 0fd7029c48dc045f29595582e24434c1b89e2076 (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
´╗┐using System.Diagnostics;
using Tizen.Maps;
using Xamarin.Forms.Maps.Tizen;

namespace Xamarin
{
	public static class FormsMaps
	{
		static MapService _mapService = null;

		static string ProviderName { get; set; }

		static string AuthenticationToken { get; set; }

		internal static bool IsInitialized { get; private set; }

		internal static MapService MapService
		{
			get
			{
				Debug.Assert(_mapService != null, "FormsMaps is not initialized");
				return _mapService;
			}
		}

		public static void Init(string provider, string authenticationToken)
		{
			ProviderName = provider;
			AuthenticationToken = authenticationToken;
			Init();
		}

		internal static async void Init()
		{
			if (IsInitialized)
				return;
			var requestResult = await MapService.RequestUserConsent(ProviderName);
			if (requestResult)
			{
				_mapService = new MapService(ProviderName, AuthenticationToken);
				if (_mapService != null)
				{
					GeocoderBackend.Register();
					IsInitialized = true;
				}
			}
		}
	}
}