google-maps - 使用 Flutter Google Maps 插件自定义标记

官方有没有办法显示自定义标记Flutter Google Maps plugin在 map 上?根据文档找不到任何方法。

最佳答案

BitmapDescriptor customIcon;

// make sure to initialize before map loading
BitmapDescriptor.fromAssetImage(ImageConfiguration(size: Size(12, 12)),
        'assets/images/car-icon.png')
    .then((d) {
  customIcon = d;
});

final nearbyCarsLocation = [
  LatLng(24.9286825, 67.0403249),
  LatLng(24.985577, 67.0661056), //24.9294892,67.0391903,18.73z
];

void _getNearByCars() {

  for (var i = 0; i < nearbyCarsLocation.length; i++) {
    var now = new DateTime.now().millisecondsSinceEpoch;
    _markers.add(Marker(
      markerId: MarkerId(nearbyCarsLocation[i].toString() + now.toString()),
      position: nearbyCarsLocation[i],
      // infoWindow: InfoWindow(title: address, snippet: "go here"),
      icon: customIcon ));
  }
  notifyListeners();
}

希望这将有助于获得自定义附近的地区

https://stackoverflow.com/questions/52591556/

相关文章:

dart - Flutter:如何检测键盘按Enter?

flutter - 获取相对于小部件的点击位置

android-studio - 在指定位置找不到 Flutter SDK - 在 Android

dart - 如何在 Google Maps Flutter 插件上添加折线?

dart - 如何使用 flutter 删除 Firestore 文档中的字段

dart - 将 "uint8list"的字符串转换为 Unit8List

android - Flutter 从 1.5 升级到 1.7.4 后 APK 大小翻倍?

dart - 如何在 Flutter 小部件测试中等待 future 完成?

database - 如何在 sqflite 的数据库中创建多个表?

dart - 向 Flutter 应用添加不同的路由/屏幕