【发布时间】:2021-10-15 15:49:46
【问题描述】:
我在我的应用中使用了 google_maps_flutter 包,默认的 myLocation 样式在 iOS 和 Android 平台之间是不同的。
我更喜欢iOS风格,哪个按钮在右下角,圆形。 但在Android中就完全不同了,矩形并放置在右上角。
是否有可能将按钮的样式从Android更改为iOS?
【问题讨论】:
标签: flutter google-maps dart
我在我的应用中使用了 google_maps_flutter 包,默认的 myLocation 样式在 iOS 和 Android 平台之间是不同的。
我更喜欢iOS风格,哪个按钮在右下角,圆形。 但在Android中就完全不同了,矩形并放置在右上角。
是否有可能将按钮的样式从Android更改为iOS?
【问题讨论】:
标签: flutter google-maps dart
您可以尝试创建自定义按钮。将myLocationButtonEnabled 设置为false 并在Google Maps 小部件中创建FloatingActionButton。
GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _yourLocation,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
}, ),
myLocationEnabled: true,
myLocationButtonEnabled: false,
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.white,
foregroundColor: Colors.grey,
elevation: 5,
onPressed: () => _getCurrentLocation(),
child: Icon(Icons.my_location)),
),
);
}
然后使用location 或geolocator 包实现自定义_getCurrentLocation() 方法。
【讨论】: