Reputation: 21
I have problem with drawing polygon around polyline(( I have all coordinates polyline and i want to buffer the coordinates to get coordinates of polygon around this polyline.
But I want to make something like this:
please help...
Upvotes: 2
Views: 2065
Reputation: 546
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)
}
}
Upvotes: 0
Reputation: 191
You can just draw 2 polylines with same path.
Let's say you've created a variable thePath
with buffered coordinates.
You've already created a polyline with this path.
let redPolyline = GMSPolyline()
redPolyline.path = thePath
redPolyline.map = mapview
Create another one.
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
Remember to that redPolyline's zIndex
should be higher than the bluePolyline because as i can see in the image you've provided, redPolyline is on top of the other one.
Upvotes: 2