在Google Map中单击按钮时出现抖动时重建标记

时间:2020-11-05 06:45:28

标签: flutter google-maps markers

我需要使用flutter从firestore中获取位置的数据,我具有位置列表和这些位置的标记,但是当我单击按钮时,列表会使用新位置再次重建,但是标记没有,我需要重新启动我的应用程序以便重建并显示标记?

               child: BlocBuilder<AddBloc, AddState>(
                  builder: (context, state) {
                    if (state is AddGetMarkerPositionState) {
                      return buildMap(state.marker);
                    } else if (state is AddErrorState) {
                      return Text(state.message);
                    } else if (state is AddCoordinatesCatchedState) {
                      return buildMap(state.marker);
                    } else if (state is AddErrorState) {
                      return Text(state.message);
                    } else {
                      return Container(
                        width: 0,
                        height: 0,
                      );
                    }
                  },
                ),
              ),
              Search(),
              PlacesList()
            ],
          ),
        ),
        bottomNavigationBar: NavBarWidget(),
      ),
    );
  }

  Widget buildMap(Set<Marker> marker) {
    return GoogleMap(
      markers: marker,
      mapType: MapType.satellite,
      myLocationEnabled: true,
      initialCameraPosition: CameraPosition(
        target: _center,
        zoom: 13.0,
      ),
      onMapCreated: _onMapCreated,
    );
  }
}

0 个答案:

没有答案
相关问题