2017-10-06 336 views
0

我嘗試使用mapView()函數,並且只有當我單擊標記時,選擇標記纔會更改爲自定義標記圖標。如何更改默認標記(WITH CLUSTERING)。如何在iOS中設置自定義標記圖標與標記簇Swift

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool { 

     let poiItem = marker.userData as? POIItem 
     marker.title = poiItem?.devname 
     marker.snippet = poiItem?.address 
     marker.icon = UIImage(named: "runcar1") 
     return false 
} 

image

回答

1

1:去Poitem類

再添加一個元素,該類

let marker = GMSMarker() 

添加在init方法太

,然後簡單稱爲

let myitem = POitem() 
myitem.marker = GMSMarker(latitude:0,longitude:0) 
self.map.add(myitem)