【问题标题】:How to remove default marker from GMSMapView如何从 GMSMapView 中删除默认标记
【发布时间】:2021-06-27 09:52:52
【问题描述】:

我将 GMSMapView 用于 iOS 应用程序。我想从 GMSMapView 中删除默认标记/注释,但它没有被删除。我使用 maptype 属性来删除它,它在 Android 中运行良好,但在 iOS 中它不起作用。让我在这里分享代码示例。

let camera = GMSCameraPosition.camera(withLatitude: lat, longitude: long, zoom: zoom)
mapView = GMSMapView.map(withFrame: rect, camera: camera)
mapView.mapType = .terrain //<--- it's not working somehow in code i have tried all options.

还有其他方法可以从 iOS 中的 GMSMapView 中删除所有默认标记/注释吗? 让我附上图片以提高知名度。 screen shot of issue

【问题讨论】:

    标签: ios swift google-maps-sdk-ios gmsmapview


    【解决方案1】:

    请参考这个我已经测试过它的工作

    iOS Google Maps SDK - Hide / remove labels

    首先在你的项目中添加 myStyle.json 文件,然后调用 do catch

    【讨论】:

      【解决方案2】:

      您需要自定义地图的样式,并且可以使用应用程序包中的 JSON 文件来实现。这些标记是 POI 标记,您可以使用以下命令完全删除它们:

      [
        {
          "featureType": "poi",
          "stylers": [
            {
              "visibility": "off"
            }
          ]
        }
      ]
      

      JSON 生成器:https://mapstyle.withgoogle.com/

      API 参考:https://developers.google.com/maps/documentation/ios-sdk/style-reference

      【讨论】:

        猜你喜欢
        • 2021-07-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-18
        • 2023-01-05
        • 2019-07-09
        相关资源
        最近更新 更多