ios - 如何在 iOS Swift 中设置带有标记群集的自定义标记图标

标签 ios swift swift3 google-maps-markers google-maps-sdk-ios

我已尝试使用 mapView() 函数,只有当我单击标记时,选择的标记才会更改为自定义标记图标。如何更改默认标记(带聚类)。

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 : 去 Poitem 类

向该类添加一个元素

 let marker = GMSMarker()

在初始化方法中也添加它

然后简单调用

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

关于ios - 如何在 iOS Swift 中设置带有标记群集的自定义标记图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46601314/

相关文章:

ios - 在 iOS 应用程序中创建 float 菜单

java - Realm 图像存储互操作性 Android iOS (Swift/Java)

ios - 错误: UICollectionView must be initialized with a non-nil layout parameter

Swift 3 pdf 文件下载不起作用

ios - Swift PhysicsBody 不受 Impulse 影响

javascript - 使用 getImageData 时在移动设备上获取大图像的错误数据

iOS - 更新变量值的 UI 已更改

ios - 在 Swift 中为 UIViewController 自定义 UIView

ios - 如何为 y 轴 iOS 图表设置字体

ios - WKInterfaceTable 不可选