一尘不染

Flutter Google Maps插件的自定义标记

flutter

有没有办法在地图上使用官方Flutter
Google
Maps插件
显示自定义标记?根据文档找不到任何方法。


阅读 496

收藏
2020-08-13

共1个答案

一尘不染

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();
}

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

2020-08-13