iOS Google 地图 SDK - 可以将当前位置蓝点标记为红点

Posted

技术标签:

【中文标题】iOS Google 地图 SDK - 可以将当前位置蓝点标记为红点【英文标题】:iOS Google map SDK - Is possible to current location blue dot marker to red dot 【发布时间】:2017-06-01 03:47:19 【问题描述】:

我正在使用 ios 谷歌地图 SDK,并尝试将当前位置的蓝色圆点更改为红色圆点。但我找不到路。

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

如果是,请帮助我。

提前致谢

【问题讨论】:

您尝试过自定义标记吗? 是的,我尝试用自定义标记替换当前位置图标。但自定义标记与当前位置图标不同。这里需要自定义当前位置图标颜色。 你能告诉我当前的图标吗? 需要将当前位置的蓝色圆点标记更改为其他颜色,就像在 iOS Uber 应用程序中一样。 marker.icon = GMSMarker.markerImage(with: .black) 【参考方案1】:

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

【讨论】:

感谢您的想法。替换图标图像可能有效。如果我提供 pod update,它将被替换。 感谢这个解决方案对我有用。只需要知道它是否被谷歌允许。我尝试阅读文档,但找不到任何线索。【参考方案2】:

只需更改色调颜色。 mapView.tintColor = UIColor.red

【讨论】:

【参考方案3】:

您应该包括 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。

以上是关于iOS Google 地图 SDK - 可以将当前位置蓝点标记为红点的主要内容,如果未能解决你的问题,请参考以下文章

iOS google maps sdk GMSMarker 定位

google-maps-sdk-ios - 适用于 iOS 的 Google 地图 1.4.3 的 arm 7/iphone 5 问题

Google Maps iOS SDK - 搜索地点

如何在 swift 中为 ios 的 google maps sdk 中的地图视图添加标记

将 Google Map SDK 添加到 iOS6 时将错误无法识别的选择器发送到类

Flutter:将 iOS 上的 Google Maps SDK 从 3.9.0 更新到 4.1.0.0