setMapStyle method

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

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 String? errorDescription = await _hostApi(
    mapId,
  ).setStyle(mapStyle ?? '');
  if (errorDescription != null) {
    throw MapStyleException(errorDescription);
  }
}