2016-09-22 63 views

回答

2

你可以只畫2個折線與相同的路徑。

假設您已創建了具有緩衝座標的變量thePath。 您已經使用此路徑創建了折線。

let redPolyline = GMSPolyline() 
redPolyline.path = thePath 
redPolyline.map = mapview 

創建另一個。

let redPolyline = GMSPolyline() 
redPolyline.path = thePath 
redPolyline.strokeWidth = 6.0 // Change it accordingly 
redPolyline.strokeWidth = UIColor.redColor().colorWithAlphaComponent(0.5) // Change it accordingly 

redPolyline.map = mapview 

記住這redPolyline的zIndex應該比bluePolyline高,因爲我可以根據您提供的圖片中看到,redPolyline是另一個的上面。

+0

是的,但它不是很正確的決定。我需要設置繪製該多邊形的距離,因爲我需要添加更多的點(Google地方),這是在小區域(例如20公里) 此決定何時接近polilayn區域也減少(( ) Java和Java腳本有解決方案https://github.com/dr-jts/jts/tree/master/modules/core/src/main/java/org/locationtech/jts/operation/buffer –

0
If you want to draw polygone on Google map with array coordinates use this function: 

func addPloygone(){ 
     let path = GMSMutablePath() 
     path.removeAllCoordinates() 
     for i in places{ 
      path.add(CLLocationCoordinate2D(latitude:i.lon!, longitude:i.lat!)) 
      let polyline = GMSPolygon(path: path) 
      polyline.geodesic = true 
      polyline.map = map 
      polyline.strokeColor = UIColor.black 
      polyline.fillColor = UIColor.init(colorLiteralRed:176/255, green: 143/255, blue:52/255, alpha: 0.6) 
     } 
    }