iOS谷歌地图SDK - 是否可以将当前位置的蓝点标记改为红点?

3

我正在使用iOS版Google地图SDK,尝试将当前位置的蓝色点改为红色点,但我找不到方法。

是否有可能将当前位置的蓝色点更改为自定义(红色点)颜色?

如果可以,请帮我解决这个问题。

提前感谢您的帮助。


你尝试过自定义标记吗? - Abhishek Sharma
是的,我尝试用自定义标记替换当前位置图标。但是自定义标记与当前位置图标不同。在这里,我需要自定义当前位置图标的颜色。 - Dsh
你能展示一下当前的图标吗? - Abhishek Sharma
1
需要将当前位置的蓝色点标记更改为iOS Uber应用程序中的其他颜色。 - Dsh
marker.icon = GMSMarker.markerImage(with: .black) 标记.icon = GMSMarker.markerImage(使用:.black) - Abhishek Sharma
3个回答

4

如图所示找到路径

如果您想更改当前位置图标,只需在谷歌地图资源中找到GMSSprites-0-1x.png图标,并用所需的图标替换它们即可。


谢谢您的建议。替换图标图片可能会起作用。如果我执行pod update,那么它将被替换。 - Dsh
谢谢,这个解决方案对我很有用。只是需要知道是否被Google允许。我尝试阅读文档但没有找到任何线索。 - Muhammad Usman Aleem

1

只需更改色调颜色。

mapView.tintColor = UIColor.red

-1

你应该包含MKMapViewDelegate。调用该方法

- (MKAnnotationView *)mapView:(MKMapView *)mapView 
        viewForAnnotation:(id<MKAnnotation>)annotation;

将注释视图更改为您喜欢的自定义视图。 您可以提供任何图像。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

static NSString* AnnotationIdentifier = @"Annotation";
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];

if (!pinView) {

    MKPinAnnotationView *customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];   
    if (annotation == mapView.userLocation){
       customPinView.image = [UIImage imageNamed:@"YourLocationimage.png"];
    }
    else{
        customPinView.image = [UIImage imageNamed:@"Notyourlocationimage.png"];
    }
    return customPinView;

} else {

    pinView.annotation = annotation;
}

return pinView;
}

OP 询问的是 Google 地图,不是 MapKit。 - Edward L.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接