Swift Google Maps平滑四舍五入 [英] Swift Google Maps smoothly rounded polylines

查看:84
本文介绍了Swift Google Maps平滑四舍五入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS语言的GoogleMaps Swift语言.

I'm using GoogleMaps for iOS platform, Swift language.

我根据Google Maps文档绘制了路径:

I draw the path according to the Google Maps documentation:

 let path = GMSMutablePath()
 path.add(previousLocation)
 path.add(currentLocation)

 let line = GMSPolyline(path: path)
 line.strokeWidth = 5
 line.strokeColor = .blue
 line.map = mapView

我的客户抱怨路线交点必须平滑倒圆.我该如何实施?有什么建议吗?

My client complains that the route lines intersections must be smoothly rounded. How can I implement this? Some suggestions?

谢谢!

推荐答案

我找到了解决方案. 我的问题是我总是只画最后两点:

I found the solution. My problem was that I was always drawing only the last two points:

 let path = GMSMutablePath()
 path.add(previousLocation)
 path.add(currentLocation)

现在,每次出现新位置时,我都会清除地图并重新绘制整个路线:

Now, every time when a new location comes, I clear the map and redraw again the entire route:

 mapView.clear()

 let path = GMSMutablePath()   
 for location in locationsArray {
     path.add(location)
 }

 let line = GMSPolyline(path: path)
 line.strokeWidth = 5
 line.strokeColor = .blue
 line.map = mapView

似乎Google Maps以这种方式正确绘制了路线.

Seems that in this way Google Maps draws the route correctly.

这篇关于Swift Google Maps平滑四舍五入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆