可调整大小的GMSCircle GoogleMaps SDK for iOS。

3

有没有办法调整(缩小和扩大)GMSCircle对象的大小? 我创建了GMSCircle并将其附加到我们的地图上。

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

我想让圆形响应我的手势来调整大小,并获取其圆的半径值。例如,这里有一个网络版的示例(点击此处)
那么如何创建呢?感谢您的任何帮助。谢谢!

嘿,你找到任何解决方案了吗? - Apple
@Apple目前还没有找到解决方案,所以我只好为圆的半径值创建滑块。 - Sonic Master
能否在地图上移动和调整圆形大小?我对此表示怀疑,因为我仍然找不到任何相关的解决方案。如果你有任何想法,我在这里发了一个问题,请回复:http://stackoverflow.com/questions/40991640/resize-drag-and-scale-gmscircle-in-google-map-objective-c - Apple
@SonicMaster,你能分享一下你的代码吗? - Darshan Mothreja
1个回答

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)   
 }

1
感谢提供这个动态圆形。 - Raksha Saini

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接