跟踪用户当前位置后,iOS的Google地图我的位置按钮颜色是什么?

4
在Google地图ios应用程序中,如果未点击当前位置,则会找到以下类似的位置按钮: Before tapping 在点击了我的位置按钮之后,它可能如下所示(蓝色)。位置按钮,而不是圆点。 After getting current location 我该如何在我的iOS应用程序中实现这个功能?请帮忙。 想要这个 blue tint 现在变成这个 gray tint 找到当前位置前和之后。

渲染按钮图像并根据需要不断更改色调颜色。 - Kaushil Ruparelia
该按钮没有任何透明度或颜色属性。 self.googleMapView.settings.myLocationButton。 - Sofeda
1个回答

0

首先,您可以使用以下代码获取当前位置 -

CLLocationCoordinate2D myLocation = self.mapView.myLocation.coordinate;

然后您可以使用GMSMarker来使用图像或颜色指示您的当前位置

 GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
    marker.title = @"Sydney";
    marker.snippet = @"Australia";
   // marker.icon = [GMSMarker markerImageWithColor:[UIColor redColor]];
    marker.icon = [UIImage imageNamed:@"point1.png"]; 
    marker.map = self.mapView;

希望上面的代码对你有所帮助。


不,我不想在我的当前位置设置标记。我只想在我的应用程序中使用Google地图iOS应用程序的上述功能。当它找到当前位置时,位置按钮的颜色就像Google地图应用程序一样。 - Sofeda
请添加以下代码:[mapView_ addObserver:self forKeyPath:@"myLocation" options:NSKeyValueObservingOptionNew context:NULL]; 然后在 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 方法中调用 self.mapView.settings.myLocationButton = YES; - Santu C
无法工作。点击我的位置按钮会将摄像头动画移动到当前位置,但我的位置按钮颜色与之前相同。 - Sofeda

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