//这种方法不会被放大缩小所影响,因为覆盖物的大小是固定的
//范围覆盖物
@property (nonatomic, strong) NSArray * yhyCircles;
#pragma mark 创建圆形覆盖物(中心点移出就请求车辆数据)
-(void)ChuangJianClireFugaiwu{
NSMutableArray *arr = [NSMutableArray array];
/* Circle. */
MACircle *circle1 = [MACircle circleWithCenterCoordinate:self.YhymapView.centerCoordinate radius:1500];
[arr addObject:circle1];
self.yhyCircles = [NSArray arrayWithArray:arr];
[self.YhymapView addOverlays:self.yhyCircles];
}
#pragma mark - MAMapViewDelegate
/**
* 地图移动结束后调用此接口
*
* @param mapView 地图view
* @param wasUserAction 标识是否是用户动作
*/
#pragma mark 地图移动结束
- (void)mapView:(MAMapView *)mapView mapDidMoveByUser:(BOOL)wasUserAction {
YhyLog(@"是否移动%d",wasUserAction);
if (self.IsChuShiHua && !wasUserAction) {
[self ChuangJianClireFugaiwu];
[self postCheLiangShuJu];
self.IsChuShiHua = false;
}
if (wasUserAction) {
if ([self.yhyCircles[0] isKindOfClass:[MACircle class]]) {
MACircle * circle = self.yhyCircles[0];
//判断是否在多边形内
if (MACircleContainsCoordinate(self.YhymapView.centerCoordinate, circle.coordinate, circle.radius)) {
YhyLog(@"在圆内");
}else{
YhyLog(@"不在圆内");
[self yichuyhyCircles:circle];
[self ChuangJianClireFugaiwu];
[self postCheLiangShuJu];
}
}
}
}