【问题标题】:TypeError: Cannot read properties of undefined (reading 'maps'). Google flutter maps webTypeError:无法读取未定义的属性(正在读取 \'maps\')。谷歌颤动地图网络
【发布时间】:2022-08-13 21:00:50
【问题描述】:

关于如何解决问题的任何想法Here

该平台是一个颤动的网络

    标签: flutter


    【解决方案1】:

    将谷歌地图脚本添加到web/index.html

    <head>
    ...
      <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
    </head>
    

    有关详细信息,请参阅google_maps_flutter_web

    【讨论】:

    • 我同时拥有google_maps_flutter_web: ^0.4.0google_maps_flutter: ^2.1.8,并且我将脚本构建为String url = 'https://maps.googleapis.com/maps/api/js?key=${dotenv.env['GMAP_API_KEY']}'; var scriptTag = html.document.getElementById("map_script"); if(scriptTag != null &amp;&amp; scriptTag.getAttribute('src') != url){ scriptTag.setAttribute( 'src', url ); } 。但我仍然得到错误。在我的 index.html 我有&lt;script id="map_script"&gt; &lt;!-- A script for map api key--&gt; &lt;/script&gt;
    【解决方案2】:

    使用终端而不是使用调试控制台进行调试。

    在终端中运行它:

    flutter run -d chrome --web-renderer html
    

    【讨论】:

      猜你喜欢
      • 2022-08-13
      • 2022-01-14
      • 2017-04-03
      • 1970-01-01
      • 1970-01-01
      • 2021-11-17
      • 2022-01-12
      • 2021-11-09
      • 2019-03-02
      相关资源
      最近更新 更多