在 flutter 应用程序中向 mapbox 添加标记

Adding marker to mapbox in flutter application

我在 flutter 应用程序中使用 Mapbox API 创建了一个地图,并使用了完美运行的 animateCamera 方法,但我需要添加一个标记在移动相机后的特定位置..这是我使用的代码:

  Future<void> movingCameraToLocation(double latitude, double longitude) async {
    await mapController.animateCamera(
      CameraUpdate.newCameraPosition(
        CameraPosition(
          bearing: 270.0,
          target: LatLng(latitude, longitude),
          tilt: 30.0,
          zoom: 21.0,
        ),
      ),
    );
  }

现在如何在此处使用的 Latlng 上添加标记?

我建议看一下 this example,它在 flutter 中将符号放置在地图的特定位置。

classPlaceSymbolBodyState实现方法_add在指定位置添加符号center:

  void _add(String iconImage) {
    controller.addSymbol(
      SymbolOptions(
        geometry: LatLng(
          center.latitude,
          center.longitude,
        ),
        iconImage: iconImage,
      ),
    );
    setState(() {
      _symbolCount += 1;
    });
  }