【问题标题】:Flutter: Is it possible to add bitmap image as ground overlay to flutter google map?Flutter:是否可以将位图图像作为地面叠加层添加到颤动的谷歌地图?
【发布时间】:2022-10-13 15:21:27
【问题描述】:

我们想使用 Flutter 在 Google 地图上给定的经纬度位置叠加显示位图图像。我正在使用颤振包 google_maps_flutter: 2.2.1,目前该包不提供实现该功能的方法。

【问题讨论】:

    标签: flutter dart flutter-layout flutter-web dart-pub


    【解决方案1】:
    //////Decalre a default marker
    BitmapDescriptor locationpinned = BitmapDescriptor.defaultMarker;
    

    然后为 locationpinned 创建一个函数,将其更改为您的图标或 png/jpeg/jpg 或任何资产 例如

    /// put this function on the initState as long as it called to be first on opening
    fromAsset() async {
               /// e.g. location of the asset
               final ping = "assets/png/ping.png";
               /// the function to change the icon
               final myCustomicon =
                    await BitmapDescriptor.fromAssetImage(ImageConfiguration.empty, ping);
               setState((){
                  locationpinned = myCustomicon;
               });
        }
    

    然后对于标记只需调用 locationpinned 放在标记图标上

        Marker(
         markerId: const MarkerId("myLocation"),
         icon: locationpinned,
         position: LatLng(
         23.1367346328462, 123.1367346328462),
     ),
    

    这就是我希望它有所帮助的全部。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-15
      • 2018-12-08
      • 2012-04-19
      • 1970-01-01
      • 2022-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多