【发布时间】:2020-08-31 18:26:15
【问题描述】:
我正在尝试为谷歌地图创建多个标记。我从 Set<Marker> markers = Set(); 开始,然后在 List 上循环并将标记添加到 markers
Marker resultMarker = Marker(
markerId: MarkerId(currentLocation.id),
infoWindow: InfoWindow(title: "${currentLocation.title}", snippet: "$snippet"),
position: LatLng(currentLocation.coordinates[1], currentLocation.coordinates[0]),
);
markers.add(resultMarker);
然后我尝试返回一个小部件:
GoogleMap(
initialCameraPosition: CameraPosition(target: _cameraPosition, zoom: 11.0),
onMapCreated: (controller) => mapController = controller,
myLocationButtonEnabled: false,
markers: markers,
);
但我只得到第一个标记,而不是全部。如何获取所有标记?
【问题讨论】:
-
你确定
markers.length不止一个吗? -
@P4yam 是的。现在是 3
-
只是在黑暗中拍摄的完整照片,但如果这些值出于某种原因是异步的并且它们都在当前位置,那么它们可能都在更新到最新的当前位置。这意味着它们可能会显示,但只是在彼此之上。我不知道您是否将三个结果标记添加到标记列表中,或者您是否有两个预定义的标记。
标签: google-maps flutter dart