3

is there any way to resize (shrink and expand) an GMSCircle object? I created GMSCircle and attach it into our maps

var cirlce: GMSCircle!

let camera = GMSCameraPosition.cameraWithLatitude(-33.86, longitude: 151.20, zoom: 6)
mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)

cirlce = GMSCircle(position: camera.target, radius: 100000)
cirlce.fillColor = UIColor.redColor().colorWithAlphaComponent(0.5)
cirlce.map = mapView

I want to make circle respond my gesture to resize and get radius value of its circle. For example, there is a web version of it here.

So how to create that? Any help would be appreciated. Thank you!

Sonic Master
  • 1,238
  • 2
  • 22
  • 36
  • Hey did you find any solution ? – Apple Dec 06 '16 at 09:56
  • @Apple haven't found any solution yet, then I just create slider for circle's radius value. – Sonic Master Dec 07 '16 at 04:13
  • is it possible to move & resize a circle in the map ? i have doubts on it.. because still i am not able to find any solution related to it. and if you have any idea then i posted a question http://stackoverflow.com/questions/40991640/resize-drag-and-scale-gmscircle-in-google-map-objective-c please do reply on it. – Apple Dec 07 '16 at 04:54
  • @SonicMaster Can you share your code – Darshan Mothreja Mar 24 '17 at 12:14

1 Answers1

4
 @IBOutlet weak var googleMaps: GMSMapView!
//Slider object to zoom in out the GMSCricle
 @IBOutlet weak var sliderer: UISlider!
 var cirlce: GMSCircle!
 var zoom: Float = 14.0
 var circleSliderZooming: Double = 1000
 var circleCenter = CLLocationCoordinate2D()
 var locationManager = CLLocationManager()


override func viewDidLoad() {
super.viewDidLoad()

locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startMonitoringSignificantLocationChanges()

self.circleview(redius: 1000)

//Your map initiation code
let camera = GMSCameraPosition.camera(withLatitude: -7.9293122, longitude: 112.5879156, zoom: zoom)
self.googleMaps.camera = camera
self.googleMaps.delegate = self
self.googleMaps?.isMyLocationEnabled = true
self.googleMaps.settings.myLocationButton = true
self.googleMaps.settings.compassButton = true
self.googleMaps.settings.zoomGestures = true
}

func circleview(redius:Double) {
   circleCenter = CLLocationCoordinate2D(latitude: -7.9293122, longitude: 112.5879156)
   cirlce = GMSCircle(position: circleCenter, radius: redius)
   cirlce.fillColor = UIColor(red: 0, green: 0, blue: 0.3, alpha: 0.2)
   cirlce.strokeColor = .blue
   cirlce.strokeWidth = 2
   cirlce.map = googleMaps 
}

 func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
  cirlce.position = position.target
 }
 //This is the Slider function to zoom in and out by Slider on View Controller
 @IBAction func cricleZoom(_ sender: Any) {
  cirlce.radius = CLLocationDistance(sliderer.value)   
 }