gpt4 book ai didi

ios - 谷歌地图折线无法完美呈现

转载 作者:技术小花猫 更新时间:2023-10-29 10:39:24 26 4
gpt4 key购买 nike

我正在使用适用于 iOS 的最新谷歌地图 API 绘制折线。我正在逐点构建多段线,但它无法正确呈现,因为当我缩小多段线时,多段线从 map 上消失(不是字面意义上的),而当我放大时,它只显示线。

Zoomed in view放大后折线是这样的

Zoomed out view这是缩小时的样子

这是我绘制折线的函数

RCPolyline *polyline = [[RCPolyline alloc] init];
[polyline drawPolylineFromPoint:self.selectedEmployee.location toPoint:location];

我已经为 RCPolyline 覆盖了 init: 是这样的

- (instancetype)init {
self = [super init];
if (self) {
self.strokeWidth = 5.0f;
self.strokeColor = UIColor.redColor;
self.geodesic = YES;
self.map = [RCMapView sharedMapView];
}
return self;}

drawPolylineFromPoint:toPoint:就是这样做的

 - (void)drawPolylineFromPoint:(CLLocation *)pointX toPoint:(CLLocation *)pointY {
GMSMutablePath *path = [GMSMutablePath path];
[path addCoordinate:pointX.coordinate];
[path addCoordinate:pointY.coordinate];
self.path = path;}

最佳答案

我发现了故障,我正在制作 RCPolyline 类的本地实例,并正在调用构造折线的方法,我想要的是为 RCPolyline 实例创建一个全局对象并更新 GMSPath RCPolyline 类实例

像这样:

- (instancetype)initWithMap:(GMSMapView *)mapView {
self = [super init];
if (self) {
self.strokeWidth = 4.0f;
self.strokeColor = [UIColor redColor];
self.geodesic = YES;
self.map = mapView;
self.mutablePath = [GMSMutablePath path];
}
return self;}

现在我从同一个实例调用这个方法。

- (void)appendPolylineWithCoordinate:(CLLocation *)location {
[self.mutablePath addCoordinate:location.coordinate];
self.path = self.mutablePath;}

PS: RCPolylineGMSPolyline 的子类

关于ios - 谷歌地图折线无法完美呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42455063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com