setStyle method

Future<void> setStyle(
  1. String style, {
  2. bool keepExistingAnnotations = true,
  3. int duration = 150,
})

Set new style for the map, using this instead of VietmapGl.styleUrl keepExistingAnnotations will keep the existing annotations on the map when the style changes, defaults to true. If set to false all existing annotations will be removed from the map when the style changes. duration is the amount of time, which awaits before the annotations are re-added to the map. This is useful if you want to show a transition value is in milliseconds.

Implementation

Future<void> setStyle(String style,
    {bool keepExistingAnnotations = true, int duration = 150}) async {
  final polygonAnnotation = polygonManager?.annotations;
  final polylineAnnotation = polylineManager?.annotations;
  final circleAnnotation = circleManager?.annotations;
  final symbolAnnotation = symbolManager?.annotations;
  await _vietmapGLPlatform.setStyle(style);
  if (keepExistingAnnotations) {
    Future.delayed(Duration(milliseconds: duration)).then((value) {
      polygonManager?.clear();
      polylineManager?.clear();
      circleManager?.clear();
      symbolManager?.clear();
      polygonManager?.addAll(polygonAnnotation ?? []);
      polylineManager?.addAll(polylineAnnotation ?? []);
      circleManager?.addAll(circleAnnotation ?? []);
      symbolManager?.addAll(symbolAnnotation ?? []);

      notifyListeners();
    });
  }
}