简体   繁体   English

如何从 GMSMapView 中删除默认标记

[英]How to remove default marker from GMSMapView

I used GMSMapView for iOS app.我将 GMSMapView 用于 iOS 应用程序。 I want to remove default marker/annotation from GMSMapView but it's not removed.我想从 GMSMapView 中删除默认标记/注释,但它没有被删除。 I use maptype property to remove it which is working perfect in Android but in iOS it's not working.我使用 maptype 属性来删除它,它在 Android 中运行良好,但在 iOS 中它不起作用。 Let me share code sample here.让我在这里分享代码示例。

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.

Is there any other way to remove all default marker/annotation from GMSMapView in iOS?有没有其他方法可以从 iOS 中的 GMSMapView 中删除所有默认标记/注释? Let me attached image for visibility.让我附上图片以提高知名度。 screen shot of issue问题截图

Please Refer this ans i have tested its working请参考这个我已经测试过它的工作

iOS Google Maps SDK - Hide / remove labels iOS 谷歌地图 SDK - 隐藏/删除标签

first add myStyle.json file in your project and then call the do catch首先在您的项目中添加 myStyle.json 文件,然后调用 do catch

You need to customize the map's style and you can do that with a JSON file in the app's bundle.您需要自定义地图的样式,您可以使用应用程序包中的 JSON 文件来实现。 Those markers are POI markers and you can remove them entirely with the following:这些标记是 POI 标记,您可以使用以下命令完全删除它们:

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

JSON generator: https://mapstyle.withgoogle.com/ JSON 发生器: https://mapstyle.withgoogle.com/

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM