gpt4 book ai didi

ios - 在谷歌地图上绘制虚线圆圈 : iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:36:54 24 4
gpt4 key购买 nike

I've been trying so hard to Draw a Dashed Circle on Google Maps but couldn't find anything helping...

几天来我一直在互联网上寻找一些在 GoogleMaps 上绘制虚线圆的解决方案,不幸的是,除了绘制一个普通的圆之外,我每次都得到答案..

这是我所做的:

map with circle

上面的代码是:

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

这是必需的:

enter image description here

最佳答案

使用 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

关于ios - 在谷歌地图上绘制虚线圆圈 : iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44886053/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com