You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何关闭Google Maps iOS SDK性能监控面板?

Google Maps性能监控面板

问题描述

我正在使用iOS版Google Maps SDK(版本9.3.0)和Google Maps Utils(版本6.1.0)。应用运行期间,性能监控窗口会自动弹出并持续显示在屏幕上。该监控面板展示调试信息和帧率,但生产环境中不应显示它,我需要禁用或关闭它。我的实现代码中没有触发该监控面板显示的显式代码。

初始化地图代码

private func initGoogleMap() {
    // 加载指定经纬度和缩放级别的地图
    let camera: GMSCameraPosition = GMSCameraPosition.camera(
        withLatitude: 37.574187,
        longitude: 126.976882,
        zoom: 15
    )

    self.mapView = GMSMapView()
    self.mapView.camera = camera
    
    // 将mapView添加到googleMapContainer
    self.googleMapContainer.addSubview(self.mapView)
    
    // 使用SnapKit设置mapView的约束
    self.mapView.snp.makeConstraints {
        $0.edges.equalToSuperview()
    }
    
    self.mapView.delegate = self
}
解决方法

这个性能监控面板是Google Maps SDK调试模式自动启用的,可通过以下方式关闭:

  • 代码显式关闭
    在初始化GMSMapView前调用GMSServices.setDebugEnabled(false)即可强制关闭调试面板,修改后的代码如下:

    private func initGoogleMap() {
        // 关闭调试信息面板
        GMSServices.setDebugEnabled(false)
        
        let camera: GMSCameraPosition = GMSCameraPosition.camera(
            withLatitude: 37.574187,
            longitude: 126.976882,
            zoom: 15
        )
    
        self.mapView = GMSMapView()
        self.mapView.camera = camera
        
        self.googleMapContainer.addSubview(self.mapView)
        
        self.mapView.snp.makeConstraints {
            $0.edges.equalToSuperview()
        }
        
        self.mapView.delegate = self
    }
    
  • 检查编译配置

    • 查看Build Settings中是否存在GOOGLE_MAPS_DEBUG编译宏,若有则移除;
    • 检查Info.plist里是否有GMSMapViewShowDebugInfo这类键,存在的话设为NO。
  • 确认SDK版本
    确保使用的是Google Maps SDK正式发布版,若通过CocoaPods引入,检查Podfile是否误选了调试变体。

内容的提问来源于stack exchange,提问作者KimJitae

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 06:02:41