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

Flutter应用iOS端Google Maps仅显示灰色屏幕(带底部Google标识)的排查求助

Flutter应用iOS端Google Maps仅显示灰色屏幕(带底部Google标识)的排查求助

大家好,我遇到了一个棘手的问题:我的Flutter应用在iOS设备上Google Maps不再显示地图瓦片了,只出现灰色屏幕,底部只有Google的logo。

我已经尝试了以下排查步骤:

  • 生成了新的Google Maps API密钥
  • 确认应用正在使用这个新密钥
  • 确保密钥没有设置任何限制
  • 已启用所需的SDK
  • 卸载并重新安装了应用
  • 确认Google计费设置正确

我比较确定这不是代码的问题,因为多个屏幕都受影响,但也有可能是兼容性问题。我的开发环境信息如下:

  • Flutter 3.32.4
  • Xcode 16.3
  • google_maps_flutter 2.12.3
  • 测试设备是运行iOS 18的物理手机

下面是受影响的其中一个页面的代码片段:

import 'package:google_navigation_flutter/google_navigation_flutter.dart';
import 'package:flutter/material.dart';

class NavigationScreen extends StatefulWidget {
  final Map<String, dynamic> journey;
  final List<Map<String, dynamic>> navigationSteps;
  final List<Map<String, dynamic>> routePoints;
  final Map<String, dynamic> startLocation;

  const NavigationScreen({
    super.key,
    required this.journey,
    required this.navigationSteps,
    required this.routePoints,
    required this.startLocation,
  });

  @override
  State<NavigationScreen> createState() => _NavigationScreenState();
}

class _NavigationScreenState extends State<NavigationScreen> {
  GoogleNavigationViewController? _controller;
  bool _navigationSessionInitialized = false;

  @override
  void initState() {
    super.initState();
    _initializeNavigationSession();
  }

  Future<void> _initializeNavigationSession() async {
    if (!await GoogleMapsNavigator.areTermsAccepted()) {
      await GoogleMapsNavigator.showTermsAndConditionsDialog(
        'Navigation Terms',
        'Please accept the terms to use navigation features.',
      );
    }

    await GoogleMapsNavigator.initializeNavigationSession(
      taskRemovedBehavior: TaskRemovedBehavior.continueService,
    );

    setState(() {
      _navigationSessionInitialized = true;
    });
  }

  void _onViewCreated(GoogleNavigationViewController controller) {
    _controller = controller;
    controller.setMyLocationEnabled(true);
  }

  @override
  void dispose() {
    if (_navigationSessionInitialized) {
      GoogleMapsNavigator.cleanup();
    }
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.journey['title'] ?? 'Navigation'),
      ),
      body: _navigationSessionInitialized
          ? GoogleMapsNavigationView(
              onViewCreated: _onViewCreated,
            )
          : const Center(child: CircularProgressIndicator()),
    );
  }
}

有没有大佬能给点建议?非常感谢!

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.08 10:49:31