The United States of America gained control from Spain by way of a treaty signed and ratified in 1821. The name of this treaty is the Onis-Adams Treaty of 1819. That was the year it was written, but it took two more years to ratify and sign. According to the United States government, Spain received no compensation for Florida after being blamed for being unable to control slaves and Native Americans that were in that area.
However, the USA did pay $5 million in damages done before Florida was signed over to the United States. At this point, the United States recognized Spanish rule over Texas. This was later renounced, but that’s not quite important to how the United States gained control of Florida.