【发布时间】:2022-10-13 15:21:27
【问题描述】:
我们想使用 Flutter 在 Google 地图上给定的经纬度位置叠加显示位图图像。我正在使用颤振包 google_maps_flutter: 2.2.1,目前该包不提供实现该功能的方法。
【问题讨论】:
标签: flutter dart flutter-layout flutter-web dart-pub
我们想使用 Flutter 在 Google 地图上给定的经纬度位置叠加显示位图图像。我正在使用颤振包 google_maps_flutter: 2.2.1,目前该包不提供实现该功能的方法。
【问题讨论】:
标签: flutter dart flutter-layout flutter-web dart-pub
//////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),
),
这就是我希望它有所帮助的全部。
【讨论】: