using Microsoft.JSInterop;
using phronCare.UIBlazor.Shared.Components;

namespace phronCare.UIBlazor.Shared.Services
{
    public static class MapInterop
    {
        private static PhMap? CurrentInstance;
        public static void RegisterInstance(PhMap instance)
        {
            CurrentInstance = instance;
        }
        [JSInvokable("NotifyLocationChanged")]
        public static async Task NotifyLocationChanged(double lat, double lng)
        {
            if (CurrentInstance is not null)
            {
                CurrentInstance.Latitude = lat;
                CurrentInstance.Longitude = lng;
                await CurrentInstance.OnLocationChanged.InvokeAsync((lat, lng));
            }
        }
    }
}
