2017-07-27 88 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

相關問題