谷歌地图GMSMaker ICONVIEW - iOS版SDK

问题描述:

错误:谷歌地图GMSMaker ICONVIEW - iOS版SDK

value of type GMSmarker has no member iconView

如何使用ICONVIEW?

 let marker = GMSMarker() 
     marker.position = CLLocationCoordinate2D(latitude: 13.7990609, longitude: 100.5494513) 
     marker.title = "Coffee Factory" 
     marker.snippet = "Chatuchak" 
     marker.iconView = imageView 
     marker.map = mapView 

Value of type GMSmarker has no member iconView

确保您使用的是最新的谷歌地图SDK V2.3.0及以上。

试试这个:

marker.icon = UIImage(named: "<Your Image>") 

编辑:

也可以设置UIImageViewiconView

marker.iconView = UIImageView(image: UIImage(named: "<Your Image>")) 

输出:

Screen shot

希望它有帮助。

+0

我需要设置图标的UIImageView没有的UIImage – teezanateep

+0

@teezanateep你可以做两种方式,检查我的编辑答案。另外,请确保您使用的是最新的Google Maps SDK v2.3.0及更高版本。 –

+0

谢谢我的SDK版本是1.11.0 – teezanateep

你可以尝试

let marker = GMSMarker() 
    marker.position = CLLocationCoordinate2D(latitude: restaurant.latitude, longitude: restaurant.longitude) 
    marker.title = restaurant.name 
marker.icon = xyz 

这就是我与这件事。希望它也能为你工作。

雨燕3.0

let marker = GMSMarker() 

let markerImage = UIImage(named: "mapMarker")!.withRenderingMode(.alwaysTemplate) 

let markerView = UIImageView(image: markerImage) 

marker.position = CLLocationCoordinate2D(latitude: 33.5067, longitude: 51.2045) 

marker.iconView = markerView 
marker.map = mapView