gpt4 book ai didi

ios - 如何在谷歌地图iOS Sdk中拖动圆形 View

转载 作者:行者123 更新时间:2023-11-29 10:50:31 25 4
gpt4 key购买 nike

我正在使用 Google Map iOS sdk在我的 iPhone 项目中。我在这个问题上附上了一张图片,我可以画圆圈但不能将圆圈从一个位置拖到另一个位置。我正在使用以下代码绘制圆圈。我需要如图所示的 View ,还需要拖动圆圈地区。请帮助我

CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(-33.85, 151.20);
GMSCircle *circ = [GMSCircle circleWithPosition:circleCenter
radius:1000];
circ.fillColor = [UIColor grayColor];
circ.strokeColor = [UIColor redColor];
circ.strokeWidth = 5;
circ.map = mapView;

enter image description here

最佳答案

我为此调查了几个小时,但到目前为止还没有找到直接的解决方案。但是,我找到了实现这一目标的方法。解决方法是清空圆圈,拖拽的时候重新画一个新的圆圈。

如果在GMSMaker周围画了一个圆圈,可以实现拖动圆圈来实现拖动标记时调用的委托(delegate)方法:

 -(void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker {
[mapView clear];

// Re-draw marker
marker.map = mapView;

// Create your circle with the new marker
GMSCircle *circ = [GMSCircle circleWithPosition:marker.position radius:1000];
circ.fillColor = [UIColor grayColor];
circ.strokeColor = [UIColor redColor];
circ.strokeWidth = 5;
circ.map = mapView;
}

编辑:

请注意,[mapView clear] 会清除所有叠加层(包括标记)。有时这可能不是一个好的解决方案。

关于ios - 如何在谷歌地图iOS Sdk中拖动圆形 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20656095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com