Google maps iOS SDK level of detail polylines

2019-06-21 12:49发布

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:

enter image description here

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

enter image description here

2条回答
Anthone
2楼-- · 2019-06-21 13:21

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
查看更多
三岁会撩人
3楼-- · 2019-06-21 13:27

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.

查看更多
登录 后发表回答