如何在两个 MKCooperativeRegion 之间建立并集
我正在尝试在两个 MKCooperativeRegion 之间进行并集。有人知道如何做到这一点吗?
I'm trying to do the union between two MKCoordinateRegion. Does anybody have an idea on how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一个
MKMapRectUnion
函数接受两个MKMapRect
,因此您可以首先将每个MKCooperativeRegion
转换为MKMapRect
,然后调用该函数(并使用MKCooperativeRegionForMapRect
函数将结果转换回MKCooperativeRegion
)。转换方法可能如下所示:
然后,实际进行并集:
There is a
MKMapRectUnion
function which accepts twoMKMapRects
so you could first convert eachMKCoordinateRegion
to anMKMapRect
and then call that function (and convert the result back to anMKCoordinateRegion
using theMKCoordinateRegionForMapRect
function).The conversion method might look like this:
Then, to actually do the union:
如果有人正在寻找使用扩展的快速等效项,
并且可以像这样使用
If anyone is looking for a swift equivalent using extensions,
And can be used like
我在 4.3 和 5.0 上做了一些测试,似乎转换不正确
14.718256、-40.078125、63.837150、70.312500
78118912.000000、94811514.406252、52428800.000000、52428799.999997
17.416993、-40.078125、63.837150、70.312500
78118912.000000、91803983.982924、52428800.000000、53344239.567355
20.649080、-40.078125、63.837150、70.312500
78118912.000000、87976363.978412、52428800.000000、54699220.734715
24.548345、-40.078125、63.837150、70.312500
78118912.000000、82962597.189840、52428800.000000、56765991.576236
29.305644、-40.078125、63.837150、70.312500
78118912.000000、76093086.024249、52428800.000000、60073659.997575
i did a little test on both 4.3 and 5.0 and it seems that the conversion is not correct
14.718256, -40.078125, 63.837150, 70.312500
78118912.000000, 94811514.406252, 52428800.000000, 52428799.999997
17.416993, -40.078125, 63.837150, 70.312500
78118912.000000, 91803983.982924, 52428800.000000, 53344239.567355
20.649080, -40.078125, 63.837150, 70.312500
78118912.000000, 87976363.978412, 52428800.000000, 54699220.734715
24.548345, -40.078125, 63.837150, 70.312500
78118912.000000, 82962597.189840, 52428800.000000, 56765991.576236
29.305644, -40.078125, 63.837150, 70.312500
78118912.000000, 76093086.024249, 52428800.000000, 60073659.997575