2017-07-27 31 views
1

我使用Google地图的默认蓝色当前位置指示器(通过以下代码)。在iOS版Google地图SDK中更改我的位置指示器颜色

mapView.isMyLocationEnabled = true 

我需要改变它的颜色。有什么办法可以改变颜色吗?

我明白,如果这是不可能的我可以使用制造商的外观是可配置的,但如果我不断更新制造商的位置,它不会像默认位置指示器一样平稳。

+0

更改tintColor描述的方式自定义颜色不为我工作... –

回答

-1
self.mapView.tintColor = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1) 

是它的工作原理尝试添加

import MapKit 
import CoreLocation 

let manager = CLLocationManager() 
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 

    let location = locations[0] 

    let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01, 0.01) 
    let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude) 
    let region:MKCoordinateRegion = MKCoordinateRegionMake(myLocation, span) 
    mapView.setRegion(region, animated: true) 


    self.mapView.showsUserLocation = true 
    self.mapView.tintColor = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1) 


} 

的Cuz我的名声是低我不能添加图像,但它的作品。

+0

设置tingColor似乎没有工作,它是否在你的项目上工作? –

+0

是的,它的工作原理,尝试添加 –

+0

你使用哪个版本的SDK?我的项目是GoogleMaps(2.3.1) –

-1

您可以更改位置指示灯的颜色通过以下方式

self.mapView.tintColor = UIColor.gray 

,或者如果你想与阿尔法您可以使用上面

self.mapView.tintColor = UIColor(red: 120/255, green: 120/255, blue: 50/255, alpha: 1) 
+0

GoogleMaps GMSMapView没有[tintColor](https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_map_view) – Efren

相关问题