首页 > 解决方案 > 缩小后折线开始消失

问题描述

我遇到了一个奇怪的问题,当我缩小自定义坐标的折线开始消失时,以下是我的代码

 func setTrackerLines(currentLoc: String, destinationLoc: String) {
        let str1 = currentLoc
        let LocArray1 = str1.components(separatedBy: ",")
        let str2 = destinationLoc
        let LocArray2 = str2.components(separatedBy: ",")

        let path = GMSMutablePath()
        path.add(CLLocationCoordinate2D(latitude: (LocArray1[0] as NSString).doubleValue, longitude: (LocArray1[1] as NSString).doubleValue))
        path.add(CLLocationCoordinate2D(latitude: (LocArray2[0] as NSString).doubleValue, longitude: (LocArray2[1] as NSString).doubleValue))

        let rectangle = GMSPolyline(path: path)
        rectangle.strokeColor = UIColor.blue
        rectangle.strokeWidth = 1
        rectangle.map = self.myMapView
    }
}

在 viewdidload() 上调用了这个方法,这就是我使用代码的方式

  for i in 0 ..< pointArray.count {
        print("Delta: \(delta)")
        if pointArray.count != (i + 1) {
            self.setTrackerLines(currentLoc: pointArray[i], destinationLoc: pointArray[i + 1])

    }

结果显示在图片中。请帮忙

折线显示 在特定缩放级别没有折线

标签: iosswiftgoogle-mapsgoogle-maps-markersgoogle-polyline

解决方案


推荐阅读