在Google地图目标-c中调整GMSCircle的大小,拖动和缩放
Helllo Everyone,在谷歌地图中我需要显示一个圆圈,用户可以调整它,缩放它并拖动它然后我需要找到圆的半径和中心经度和纬度。 我怎样才能做到这一点?
适用于Tappable GMSCircle套装
googleMapCircle.tappable = true;
并且要实现可拖动的圆圈需要添加Google地图didTapOverlay
的委托方法:
- (void)mapView: (GMSMapView*)mapView didChangeCameraPosition: (GMSCameraPosition*)position { //set GMSCameraPosition to googleMapCircle position googleMapCircle.position=position.target; }
用于在滑块值更改时调整GMSCircle的大小在滑块值更改方法中添加以下代码:
- (IBAction)sliderValueChnage:(id)sender { _slider = (UISlider*)sender; NSLog(@"slider value = %f", _slider.value); int radius=(int)_slider.value; _lblRadius.text=[NSString stringWithFormat:@"%dm",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; }