Google maps iOS SDK level of detail polylines

无人久伴 提交于 2019-12-23 10:19:25

问题


I am using the Google Maps iOS SDK to draw a list of polylines. The polylines come from a server, and for each next polyline, the starting point corresponds with the end point of the previous polyline.

I notice that Google Maps changes the level of detail of the polylines at different zoom levels, probably an optimisation thing. This results in small gaps between the several polylines at lower zoom levels.

The reasons behind splitting a polyline up in several smaller lines are not up to me, this is what the system defines for me. I know I may be able to combine the several polylines into one single large polyline, but I was wondering: does the SDK allow the setting for this level of detail? Or is there maybe another fix?

Zoomed out, notice the gaps:

Almost fully-zoomed in, the gaps are nearly gone:


回答1:


I have found no answer so far, so what I did, was traversing all geo-coordinates in-order (luckily my data-structure allows this), collect them in an array, encode this array to a Google Encoded Polyline (GEP) as per https://gist.github.com/mmdumi/3999640, and then display this on the map using [GMSPolyLine polylineWithPath:]. As far as I can tell, there is no way to instantiate a GMSPolyLine other than using a GEP.




回答2:


I have found no answer too, but, there are two ways :

  1. You can draw the entire line like a for sentence and draw, for example :

    path.add(CLLocationCoordinate2D(latitude: latitude_,longitude: longitude_)) let polyline = GMSPolyline(path: path) polyline.strokeColor = .red polyline.map = mapView polyline.strokeWidth = 2

or

  1. https://github.com/raphaelmor/Polyline


来源:https://stackoverflow.com/questions/30393067/google-maps-ios-sdk-level-of-detail-polylines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!