前言:百度地图API并没有提供移动地图时的回调接口
实现:通过判断当前地图的中心位置是否为用户位置来判断,代码如下
-(void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated { if (![self isCoordinateA:_mapView.centerCoordinate equalToCoordinateB:_location.coordinate]){
UserLocationInCenter = NO;
}
} -(BOOL)isCoordinateA:(CLLocationCoordinate2D )locA equalToCoordinateB:(CLLocationCoordinate2D)locB{ CLLocation *locationA = [[CLLocation alloc]initWithLatitude:locA.latitude longitude:locA.longitude];
CLLocation *locationB = [[CLLocation alloc]initWithLatitude:locB.latitude longitude:locB.longitude]; CGFloat dist= [locationA distanceFromLocation:locationB]; if(dist <5){
return YES;
}
return NO;
}