xxxxxxxxxx
List<Marker> _markers = []
_markers.add(
Marker(
markerId: MarkerId('SomeId'),
position: LatLng(38.123,35.123),
infoWindow: InfoWindow(
title: 'The title of the marker'
)
)
);
GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(38.9647,35.2233),
zoom: 9.0,
),
mapType: MapType.normal,
markers: Set<Marker>.of(_markers),
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
)
xxxxxxxxxx
Future<Uint8List> getBytesFromAsset(String path, int width) async {
ByteData data = await rootBundle.load(path);
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
targetWidth: width);
ui.FrameInfo fi = await codec.getNextFrame();
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))!
.buffer
.asUint8List();
}
// init marker icon
final Uint8List markerIcon2 =
await getBytesFromAsset('assets/images/m1.png', 99);
final Uint8List markerIcon1 =
await getBytesFromAsset('assets/images/camion.png', 139);
teste1 = BitmapDescriptor.fromBytes(markerIcon2);
teste2 = BitmapDescriptor.fromBytes(markerIcon1);
// show marker
Marker(icon: teste1)
Marker(icon: teste2)