CLLocationCoordinate2D

CLLocationCoordinate2D

本文介绍了我如何检查CLLocationCoordinate2D是否在四个CLLocationCoordinate2D Square内?在Objective C中使用Google地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试一个CLLocationCoordinate2D是否在由其他四个CLLocationCoordinate2D创建的Square中我有这样一个结构:

  typedef struct {
CLLocationCoordinate2D southWest;
CLLocationCoordinate2D southEast;
CLLocationCoordinate2D northEast;
CLLocationCoordinate2D northWest;
}界限;

以参数形式传递CLLocationCoordinate2D坐标。我想测试坐标是否在边界内。

   - (BOOL)isCoordinate:(CLLocationCoordinate2D)coordinate insideBounds:(Bounds)bounds {... } 


解决方案

如果你有四点,你可以制作CGRect并使用CGRectContainsPoint()


I want to test if a CLLocationCoordinate2D is inside a Square created from other four CLLocationCoordinate2D

I have a struct like this:

typedef struct {
    CLLocationCoordinate2D southWest;
    CLLocationCoordinate2D southEast;
    CLLocationCoordinate2D northEast;
    CLLocationCoordinate2D northWest;
} Bounds;

And a CLLocationCoordinate2D coordinate passed as param. And I want to test if coordinate is inside the Bounds. How can I test that?

- (BOOL) isCoordinate:(CLLocationCoordinate2D)coordinate insideBounds:(Bounds)bounds { ... }
解决方案

If you have four points you can make a CGRect and use CGRectContainsPoint()

这篇关于我如何检查CLLocationCoordinate2D是否在四个CLLocationCoordinate2D Square内?在Objective C中使用Google地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 20:58