Reputation: 424
I'm trying to draw a dotted polyline on GMSMapView. What I've achieved so far is to add a dashed polyline on the map. For which I've written below code:
polyLine.strokeWidth = 10
polyLine.strokeColor = UIColor(red: 95/255, green: 89/255, blue: 89/255, alpha: 1.0)
let styles: [GMSStrokeStyle] = [GMSStrokeStyle.solidColor(UIColor.clear), GMSStrokeStyle.solidColor(UIColor.red)]
let scale = 1.0 / testMap.projection.points(forMeters: 1, at: testMap.camera.target)
let solidLine = NSNumber(value: 10.0 * Float(scale))
let gap = NSNumber(value: 10.0 * Float(scale))
let span = GMSStyleSpans(polyLine.path!, styles, [solidLine, gap], GMSLengthKind.rhumb)
polyLine.spans = span
With this code, I'm getting a polyline with 10x10 squares as dashes.
For dotted polyline I've tried to set the dot image as one of the solid color in GMSStrokeStyle like below:
let styles: [GMSStrokeStyle] = [GMSStrokeStyle.solidColor(UIColor(patternImage: UIImage(named: "dot1.jpg")!)), GMSStrokeStyle.solidColor(UIColor.red)]
One more solution I've tried for the same is here
With this solution, the map takes significant amount of time to load and refresh. Because of which the application hangs on loading the map.
What are other approaches to draw a Dotted Polyline on Google Map in ios?
Upvotes: 2
Views: 513