@using phronCare.UIBlazor.Shared.Services @inject IJSRuntime JS
Mapa de Ubicación
@if (EnableAddressSearch) { }
@code { private string MapDivId = $"map_{Guid.NewGuid()}"; public static PhMap? CurrentInstance { get; private set; } private double _latitude = -34.6037; private double _longitude = -58.3816; [Parameter] public double Latitude { get => _latitude; set => _latitude = value; } [Parameter] public double Longitude { get => _longitude; set => _longitude = value; } [Parameter] public int Zoom { get; set; } = 13; [Parameter] public bool EnableAddressSearch { get; set; } = true; [Parameter] public EventCallback<(double lat, double lng)> OnLocationChanged { get; set; } private string SearchAddress { get; set; } = string.Empty; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { MapInterop.RegisterInstance(this); // ✅ esto conecta con MapInterop.cs await Task.Delay(100); await JS.InvokeVoidAsync("phMap.initMap", MapDivId, Latitude, Longitude, Zoom); } } private async Task CenterByAddress() { if (!string.IsNullOrWhiteSpace(SearchAddress)) await JS.InvokeVoidAsync("phMap.searchAddress", MapDivId, SearchAddress); } private void OpenGoogleMaps() { var url = $"https://www.google.com/maps?q={_latitude.ToString(System.Globalization.CultureInfo.InvariantCulture)},{_longitude.ToString(System.Globalization.CultureInfo.InvariantCulture)}"; JS.InvokeVoidAsync("window.open", url, "_blank"); } }