setMapStyle method

  1. @override
Future<void> setMapStyle(
  1. String? mapStyle, {
  2. required int mapId,
})
override

Sets the styling of the base map.

Set to null to clear any previous custom styling.

If problems were detected with the mapStyle, including un-parsable styling JSON, unrecognized feature type, unrecognized element type, or invalid styler keys: MapStyleException is thrown and the current style is left unchanged.

The style string can be generated using map style tool.

Implementation

@override
Future<void> setMapStyle(
  String? mapStyle, {
  required int mapId,
}) async {
  final List<dynamic> successAndError = (await channel(mapId)
      .invokeMethod<List<dynamic>>('map#setStyle', mapStyle))!;
  final bool success = successAndError[0] as bool;
  if (!success) {
    throw MapStyleException(successAndError[1] as String);
  }
}