首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用google direction api绘制路径

使用google direction api绘制路径
EN

Stack Overflow用户
提问于 2017-03-20 01:24:33
回答 2查看 342关注 0票数 0

我试图用google direction api在多个地方之间绘制路径,但问题是当我缩放地图时,路径不能正确绘制。

我正在点击这个api,并从JSON的响应中画出带有'overview_polyline‘点的路径。

https://maps.googleapis.com/maps/api/directions/json?origin=(startLocationLat),(startLocationLong)&destination=(endLocationLat),(endLocationLong)&waypoints=(self.wayPointBetweenLocations)&key=AIzaSyCK0dxRGRlFqM84SUM3zbVQAdbXEXtN-x0&mode=driving

代码语言:javascript
复制
let polygon = GMSPolygon()
polygon.path = GMSPath(fromEncodedPath: "\(self.overview_points)")

请帮我弄一下这个。谢谢

EN

回答 2

Stack Overflow用户

发布于 2017-03-20 19:39:50

使用GMSPolyline而不是GMSPolygon绘制路径。

示例

代码语言:javascript
复制
    let path = GMSPath(fromEncodedPath: "\(self.overview_points)")
    let directionPolyline = GMSPolyline(path: path)
    directionPolyline.strokeColor = UIColor.blue
    directionPolyline.strokeWidth = 3
    directionPolyline.map = self.mapView
票数 1
EN

Stack Overflow用户

发布于 2017-12-07 17:59:08

尝试使用Google Maps Roads API part Snap to Roads获取来自JSON响应的点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42889685

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档