我如何检查CLLocationCoordinate2D是否在四个CLLocationCoordinate2D Square内?在Objective C中使用Google地图 [英] How can I check if a CLLocationCoordinate2D is inside four CLLocationCoordinate2D Square? in Objective C with Google Maps

查看:124
本文介绍了我如何检查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地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆