Resize, drag and scale GMSCircle in Google map objective-c

China☆狼群 提交于 2019-12-08 06:29:54

问题


Helllo Everyone, In google map i need to show a circle and user can resize it, scale it and drag it also and after that i need to find radius of the circle and center latitude and longitude. How can i achieve this ?


回答1:


For Tappable GMSCircle set

googleMapCircle.tappable = true;

And to achieve draggable circle need to add the delegate method of Google map didTapOverlay :

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

}

For resize GMSCircle on slider value change Add below code in slider value change method :

- (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;


}



来源:https://stackoverflow.com/questions/40991640/resize-drag-and-scale-gmscircle-in-google-map-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!