用mapbox插件在flutter地图上添加自定义标记。

问题描述 投票:-3回答:1

为了给我的应用提供一个更好的用户界面,我需要显示一个小卡片,上面有用户的名字和一个小圆圈,上面有用户的图片或头像。

有什么方法可以用flutter-mapbox-gl插件来实现吗?

flutter mapbox mapbox-gl
1个回答
0
投票

最好的解决方案是在mapbox-gl包例子文件夹里面 。https:/github.comtobrunflutter-mapbox-glblobmasterexamplelibplace_symbol.dart。

这里有一个小例子,你可以做什么

Widget build(BuildContext context) {

  mapController.addSymbol(
  SymbolOptions(
    geometry: LatLng(-33.86711, 151.1947171),
    iconImage: "assets/images/ur_image.png",
  ),
); 
 return Scaffold(
  body: Center(
        child: SizedBox(
          width: double.infinity,
          height: 300.0,
          child: MapboxMap(
            styleString: themeControl.themeSet.mapStyle,
            onMapCreated: _onMapCreated,
            onStyleLoadedCallback: _onStyleLoaded,
            zoomGesturesEnabled: _zoomGesturesEnabled,
            myLocationEnabled: _myLocationEnabled,
            initialCameraPosition: const CameraPosition(
              target: LatLng(-33.852, 151.211),
              zoom: 11.0,
            ),
          ),
        ),
      ),
);}
© www.soinside.com 2019 - 2024. All rights reserved.