Container(
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(currentPosition.latitude,
currentPosition.longitude),
zoom: 16.0),
zoomGesturesEnabled: true,
//still need somewhere to display other set of created markers
markers: Set<Marker>.of(markers),
如您所见,这是Flutter上的Google Maps片段。我想要做的是添加多组标记列表,例如,我有另一个要添加的标记列表,但我似乎无法弄清楚是否有可能
markers: Set<Marker>.of(markers),
除了构建方法外,我还有另一个标记列表,需要将它们添加到同一Google Map中:
final Set<Marker> _secondMarkers= {};
我想这需要在此处添加,但不允许有多个列表。是否有另一个简单的解决方案?我已经绞尽脑汁了好几个小时,尝试将.add添加到集合中,但不允许这样做。有一种干净的方法可以做到这一点,还是我应该尝试其他解决方案?
答案 0 :(得分:2)
如果添加到setState方法中的标记列表中,则可以添加到Set中。