2017-07-03 41 views
0

私はGoogleマップ上の破線の円を描画するために一生懸命しようとしてきたが、助けて何かを見つけることができませんでした...Googleマップ上の破線の円を描く:iOSの

を私がしてきました

... Googleマップ上の破線の円を描画するためのいくつかの解決策を見つける日間文字通りインターネット上で探して、プレーンな円を描くことは、私はすべての時間を得るものの答えよりも、残念ながら他のことはここに私がやったことだ:

上記のため

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

そのことはできませんGMSCircleで

enter image description here

答えて

1

、あなたはベースのポリラインを描画する必要が円で

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 
+0

Wonderfull ... 大変です!仕事は本当にありがとうございました。私は実際にすべての希望を失ってしまいました。 –

+0

サークルに入れてもいいですか?それらのダッシュを意味する.. –