Apple Maps 中餐厅的送货半径

Delivery radius for a restaurant in Apple Maps

我正在尝试为餐厅开发一个送货系统,但我不确定如何解决这个问题。餐厅有五个地点;其中四个处于一个状态,另一个处于不同状态。

他们只根据地点的远近为每个地点送货;他们还为每个位置设置了某些限制。

我的想法是:

我被困在哪里

尝试设置餐厅位置周围的送餐半径。你甚至可以画一个 MKCircle 来装点花样

CLLocation * _storeLocation = [[CLLocation alloc] initWithLatitude:30.270135 longitude:-97.731270];

double deliverableRadius = 3 * 1609.34; // 3 miles (or the area they will deliver to)

MKCircle * circle = [MKCircle circleWithCenterCoordinate:storeLocation.coordinate radius:deliverableRadius];
[_mapView addOverlay:circle];

确定交付区域后,您可以检查用户位置是否在该区域内。

所以我认为一个简单的方法可能是简单地检查用户是否在餐厅的一定距离内(即 "If I am less than 25 miles from a restaurant, then they will deliver to me")。

首先将餐厅位置的地址转换为 gps 坐标。有关详细信息,请参阅 Converting Place Names Into Coordinates

接下来,计算用户位置与每家餐厅位置之间的距离,并检查该距离是否小于最大送货距离。

可以找到计算两点之间距离的公式here