我正在尝试通过手指触摸调整 MkCircle 的大小。我该如何开始呢?任何人都可以建议我吗?
感谢提前。
最佳答案
我在 map View 上方绘制了具有相同半径的自定义圆,看起来像圆。
寻找MKcirlce的边缘点
- 将中心点CLLocationCoordinate2D转换为MKMapPoint
MKMapPoint centerMapPoint = MKMapPointForCoordinate(centerCoordinate)
计算圆的MKMapSize并得到宽度
double circleMapSize = mkCircle.boundingMapRect.size.width
3.在圆的周长上创建一个点。
MKMapPoint leftMostPoint = MKMapPointMake(centerMapPoint.x - circleMapSize/2.0, centerMapPoint.y)
现在从 leftMostPoint 获取 CLLocationCoordinate2D 点
CLLocationCoordinate2D leftMostCoordinateOnCircle = MKCoordinateForMapPoint(leftMostPoint)
所以现在我有了中心点和边缘点,然后将其转换为 ios 坐标的 (x,y)。
CGPoint myPoint = [self.MapView convertCoordinate:originalCoordinate toPointToView:self.MapView];
CGPoint edgePoint = [self.MapView convertCoordinate:originalCoordinate toPointToView:self.MapView];
然后我使用毕达哥拉斯定理计算这两个点的黑白距离
int distnce1=sqrt(powf(edgePoint.x- myPoint.x, 2) + powf(edgePoint.y-myPoint.y, 2));
int finalWidth=2*distnce1;
然后我将距离设置为自定义圆的宽度和高度
在 pich Gesture 再次结束后,我尝试使用圆数学来获取自定义圆的边缘纬度和经度
float x = circleView.frame.size.width/2 * sin(0)+circleView.center.x;
float y = circleView.frame.size.width/2 * cos(0)+circleView.center.y;
将x,y转换成坐标
CLLocationCoordinate2D select_coordinate = [self.MapView convertPoint:point toCoordinateFromView:self.view];
然后我找到距离 b/w 新坐标和 MKCircle 的中心点,然后将 MKCirlce 的半径更改为等于距离。
关于iphone - 如何调整 MKCircleView 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18847190/