private async void HandleWatchPositionReceived(object sender, GeolocationEventArgs e) { LastWatchPositionResult = e.GeolocationResult; if (LastWatchPositionResult.IsSuccess) { var latlng = LastWatchPositionResult.Position.ToLeafletLatLng(); var marker = new Marker(latlng, null); if (WatchPath is null) { WatchMarkers = new List <Marker> { marker }; WatchPath = new Polyline(WatchMarkers.Select(m => m.LatLng), new PolylineOptions()); await WatchPath.BindToJsRuntime(JSRuntime); await WatchPath.AddTo(WatchMap); } else { WatchMarkers.Add(marker); await WatchPath.AddLatLng(latlng); } await marker.BindToJsRuntime(JSRuntime); await marker.AddTo(WatchMap); } StateHasChanged(); }
public async void ShowCurrentPosition() { if (CurrentPositionMarker != null) { await CurrentPositionMarker.Remove(); } CurrentPositionResult = await GeolocationService.GetCurrentPosition(); if (CurrentPositionResult.IsSuccess) { CurrentPositionMarker = new Marker( CurrentPositionResult.Position.ToLeafletLatLng(), null ); await CurrentPositionMarker.BindToJsRuntime(JSRuntime); await CurrentPositionMarker.AddTo(PositionMap); } StateHasChanged(); }