【发布时间】:2021-11-15 00:30:42
【问题描述】:
我想在颤振开发时在谷歌地图的自定义标记中添加数字。 我在下面分享了我的完整来源。所以请帮助我,如何修改我的源代码来解决我的问题。谢谢 我的依赖:
custom_marker_icon: ^0.2.0
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:custom_marker_icon/custom_marker_icon.dart';
class FlutterAnimarkerExample extends StatefulWidget {
@override
_FlutterAnimarkerExampleState createState() =>
_FlutterAnimarkerExampleState();
}
class _FlutterAnimarkerExampleState extends State<FlutterAnimarkerExample> {
final LatLng _latLng = LatLng(28.7041, 77.1025);
final double _zoom = 15.0;
Set<Marker> _markers = {};
void _addMarkers() async {
BitmapDescriptor markerIcon = await CustomMarkerIcon.fromIcon(
Icons.circle,
Colors.blue,
100,
);
setState(() {
_markers.add(
Marker(
markerId: MarkerId("marker_id"),
position: _latLng,
icon: markerIcon,
),
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Custom Marker Icon Example'),
backgroundColor: Colors.red,
),
body: GoogleMap(
onMapCreated: (GoogleMapController controller) {
_addMarkers();
},
markers: _markers,
initialCameraPosition: CameraPosition(
target: _latLng,
zoom: _zoom,
),
),
);
}
}
如何修改我的代码?
【问题讨论】:
标签: android flutter google-maps dart google-maps-markers