Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在谷歌地图上画虚线圈:iOS_Ios_Objective C_Google Maps_Swift3 - Fatal编程技术网

在谷歌地图上画虚线圈:iOS

在谷歌地图上画虚线圈:iOS,ios,objective-c,google-maps,swift3,Ios,Objective C,Google Maps,Swift3,我一直在努力在谷歌地图上画一个虚线圈,但找不到任何有用的东西… 我已经在互联网上搜索了好几天,想找到一些在谷歌地图上画一个虚线圆圈的方法,不幸的是,除了画一个普通的圆圈之外,我每次都能得到答案 以下是我所做的: 以上各项的代码为: import UIKit import GoogleMaps import GooglePlaces class ViewController: UIViewController { @IBOutlet weak var gmsMapView: GMSMa

我一直在努力在谷歌地图上画一个虚线圈,但找不到任何有用的东西…

我已经在互联网上搜索了好几天,想找到一些在谷歌地图上画一个虚线圆圈的方法,不幸的是,除了画一个普通的圆圈之外,我每次都能得到答案

以下是我所做的:

以上各项的代码为:

import UIKit
import GoogleMaps
import GooglePlaces

class ViewController: UIViewController
{
    @IBOutlet weak var gmsMapView: GMSMapView!

    override func viewDidLoad()
    {
        super.viewDidLoad()

        gmsMapView.isMyLocationEnabled = true
        gmsMapView.settings.myLocationButton = true
        gmsMapView.animate(toZoom: 10.0)
        gmsMapView.animate(toLocation: CLLocationCoordinate2D(latitude: 40.709677, longitude: -74.011088))
        let circleCenter = CLLocationCoordinate2D(latitude: 40.709677, longitude: -74.011088)
        let circle = GMSCircle(position: circleCenter, radius: 5000)
        circle.strokeWidth = 2
        circle.strokeColor = UIColor.blue
        circle.map = gmsMapView
    }

    override func didReceiveMemoryWarning(){
        super.didReceiveMemoryWarning()
    }
}
这是必需的:


使用GMSCircle不可能,您必须基于圆绘制多段线

使用GMSGeometryOffset,您可以生成到位置的偏移。 360/6=60,细节更少,效率更高

let path = GMSMutablePath()

for i in 0...60 {
    let offsetLocation = GMSGeometryOffset(location.coordinate, circleRadius, CLLocationDirection(i*6))
    path.add(offsetLocation)
}
let length: [NSNumber] = [10, 10]
let circle = GMSPolyline(path: path)
let styles = [GMSStrokeStyle.solidColor(.clear), GMSStrokeStyle.solidColor(.red)]

circle.spans = GMSStyleSpans(circle.path!, styles, length, GMSLengthKind.rhumb)
circle.strokeWidth = 1.0
circle.map = mapView

好极了。。。太棒了!!它成功了非常感谢你我真的失去了所有的希望。。