【问题标题】:Google Maps GMSMaker iconView - iOS SDKGoogle Maps GMSMaker iconView - iOS SDK
【发布时间】:2017-11-05 18:57:11
【问题描述】:

错误:

GMSmarker 类型的值没有成员 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

【问题讨论】:

    标签: ios swift xcode google-maps google-maps-api-3


    【解决方案1】:

    确保您使用的是最新的 Google Maps SDK v2.3.0 及更高版本。

    试试这个:

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

    编辑:

    或者您可以将UIImageView 设置为iconView

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

    输出:

    希望对你有帮助。

    【讨论】:

    • 我需要设置图标是 UIImageView 而不是 UIImage
    • @teezanateep 你可以做这两种方式,检查我编辑的答案。此外,请确保您使用的是最新的 Google Maps SDK v2.3.0 及更高版本。
    • @teezanateep 编码快乐 :-)
    【解决方案2】:

    你可以试试

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

    【讨论】:

      【解决方案3】:

      这就是我所做的。希望它也对你有用。

      Swift 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-17
        • 2013-02-11
        • 2016-02-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多