https://meetanshi.com/magento-2-distance-based-shipping.html
Magento 2 Distance Based Shipping offers the admin to create a custom shipping method in which the shipping rate is calculated based on the unit distance between the store’s warehouse and the customer’s shipping location.
Maintaining profitability and at the same time to decide the shipping charges becomes extremely difficult for merchants. To solve this, Meetanshi has developed Magento 2 Distance Based Shipping extension.
Creating a custom shipping method to calculate shipping charges based on the distance between the warehouse and the customer’s delivery location can be done using Magento 2 Distance Based shipping module.
Flat rate shipping method is provided by the default Magento 2. However, it is not reliable for every business. For the customers’ perspective, this method is unfair because the customer who live within 1 km area and the customer who live within 10 km area, both have to pay the same amount for shipping.