тип 'GeoPoint' не является подтипом типа 'String' в пожарном депо - PullRequest
0 голосов
/ 13 июня 2019

Я пытаюсь флаттер Google Maps с Firestore, но что-то идет не так.

Вот мой код

class StoreMap extends StatelessWidget {
  const StoreMap({
    Key key,
    @required this.documents,
    @required this.initialPosition,
    @required this.mapController,
  }) : super(key: key);

  final List<DocumentSnapshot> documents;
  final LatLng initialPosition;
  final Completer<GoogleMapController> mapController;

  @override
  Widget build(BuildContext context) {
    return GoogleMap(
      initialCameraPosition: CameraPosition(
        target: initialPosition,
        zoom: 12,
      ),
      markers: documents
          .map((document) => Marker(
                markerId: MarkerId(document['placeId']),
                icon: BitmapDescriptor.defaultMarkerWithHue(_pinkHue),
                position: LatLng(
                  document['location'].latitude,
                  document['location'].longitude,
                ),
                infoWindow: InfoWindow(
                  title: document['name'],
                  snippet: document['address'],
                ),
              ))
          .toSet(),
      onMapCreated: (mapController) {
        this.mapController.complete(mapController);
      },
    );
  }
}

тип 'GeoPoint' не является подтипом типа 'String'

Firestore выглядит как

enter image description here

1 Ответ

1 голос
/ 13 июня 2019

Проблема выглядит так: MarkerId(document['placeID']), это должна быть строка.

Вы можете попробовать с помощью MarkerId(document['placeID'].toString()) или сгенерировать собственную строку на основе позиции маркера.

Не упустите placeId вместо placeID.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...