我正在使用Flutter和Google Maps API。我设法在地图打开时显示了一个自定义标记。有没有办法同时拥有多个不同的自定义标记?我找不到做到这一点的方法。
您可以用这样的东西来做
_markers.add(Marker(
consumeTapEvents: true,
position: _center,
infoWindow: InfoWindow(
title: 'New Marker',
snippet: '',
),
icon: markerImage, //you custom marker, instance of BitmapDescriptor
)
然后您使用以下方法实例化地图:
GoogleMap(
onMapCreated: (GoogleMapController controller) {
mapController = controller;
},
myLocationEnabled: locationEnable,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 10.0,
),
mapType: MapType.normal,
markers: _markers,
)