Flutter-Google Maps,同时有多个自定义标记?

问题描述 投票:0回答:1

我正在使用Flutter和Google Maps API。我设法在地图打开时显示了一个自定义标记。有没有办法同时拥有多个不同的自定义标记?我找不到做到这一点的方法。

google-maps flutter google-maps-markers marker
1个回答
0
投票

您可以用这样的东西来做

_markers.add(Marker(
      consumeTapEvents: true,
      position: _center,
      infoWindow: InfoWindow(
          title: 'New Marker',
          snippet: '',
      ),
      icon: markerImage, //you custom marker, instance of BitmapDescriptor
)

然后您使用以下方法实例化地图:

GoogleMap(
    onMapCreated: (GoogleMapController controller) {
        mapController = controller;
    },
    myLocationEnabled: locationEnable,
    initialCameraPosition: CameraPosition(
         target: _center,
         zoom: 10.0,
    ),
    mapType: MapType.normal,
    markers: _markers,
)

© www.soinside.com 2019 - 2024. All rights reserved.