ios - 在 Google map objective-c 中调整、拖动和缩放 GMSCircle

标签 ios objective-c iphone google-maps google-maps-sdk-ios

大家好,在谷歌地图中我需要显示一个圆,用户可以调整它的大小、缩放它并拖动它,之后我需要找到圆的半径和中心纬度和经度。我怎样才能做到这一点?

最佳答案

对于可点击的 GMSCircle 集

googleMapCircle.tappable = true;

而要实现可拖动的圆圈需要添加谷歌地图didTapOverlay的委托(delegate)方法:

- (void)mapView: (GMSMapView*)mapView
didChangeCameraPosition: (GMSCameraPosition*)position
{
   //set GMSCameraPosition to  googleMapCircle position
    googleMapCircle.position=position.target;

}

enter image description here

用于在 slider 值更改时调整 GMSCircle 的大小 在 slider 值更改方法中添加以下代码:

- (IBAction)sliderValueChnage:(id)sender {

  _slider = (UISlider*)sender;
    NSLog(@"slider value = %f", _slider.value);

    int radius=(int)_slider.value;
     _lblRadius.text=[NSString stringWithFormat:@"%d m",radius];


//For achieve circle radius increase or decrease properly ,first clear map view 
    [_googleMap clear];

//Set centre coordinate  where you want to draw circle
CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(_locationManager.location.coordinate.latitude, _locationManager.location.coordinate.longitude);

// Draw circle on google map
    GMSCircle *googleMapCircle = [GMSCircle circleWithPosition:circleCenter
                                             radius:_slider.value];
    googleMapCircle.fillColor = [[UIColor purpleColor] colorWithAlphaComponent:.4f];
    googleMapCircle.strokeColor = [UIColor purpleColor];
    googleMapCircle.strokeWidth = 5;
    googleMapCircle.tappable=YES;
    googleMapCircle.map = _googleMap;


}

enter image description here

enter image description here

关于ios - 在 Google map objective-c 中调整、拖动和缩放 GMSCircle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40991640/

相关文章:

xcode - Xcode 4 中的界面生成器

ios - Objective-C : NSNumber from Array to float

iphone - 如何修复错误 'No memory available to program now: unsafe to call malloc'?

iphone - 同步 AFNetworking 调用

iphone - 如何从 UIView 的内容中获取 CGImageRef?

ios - 在 subview 中居中标签

ios - 从解析中获取日期并将其显示为字符串 Swift

iOS 无法执行 HTTP GET 请求 -Error Domain=NSURLErrorDomain Code=-1012

objective-c - 在预处理器宏中包装内联 C 函数

objective-c - NSMutableArray 空数组错误