Helllo Everyone,在谷歌地图中,我需要显示一个圆圈,用户可以调整大小,缩放它并拖动它,之后我需要找到圆的半径和中心经度和纬度。我怎样才能做到这一点?
答案 0 :(得分:1)
对于Tappable GMSCircle set
didTapOverlay
要实现可拖动圈子,需要添加Google地图- (void)mapView: (GMSMapView*)mapView
didChangeCameraPosition: (GMSCameraPosition*)position
{
//set GMSCameraPosition to googleMapCircle position
googleMapCircle.position=position.target;
}
的委托方法:
- (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;
}
用于在滑块值更改时调整GMSCircle的大小 在滑块值更改方法中添加以下代码:
hostname