changeMarker method

  1. @override
Future<void> changeMarker({
  1. required GeoPoint oldLocation,
  2. required GeoPoint newLocation,
  3. MarkerIcon? newMarkerIcon,
  4. double? angle,
  5. IconAnchor? iconAnchor,
})

Implementation

@override
Future<void> changeMarker({
  required GeoPoint oldLocation,
  required GeoPoint newLocation,
  MarkerIcon? newMarkerIcon,
  double? angle,
  IconAnchor? iconAnchor,
}) async {
  var duration = 0;
  if (newMarkerIcon != null) {
    duration = 300;
    osmWebFlutterState.widget.dynamicMarkerWidgetNotifier.value =
        newMarkerIcon;
  }
  await Future.delayed(Duration(milliseconds: duration), () async {
    String? icon;
    SizeJs? iconSize;
    if (newMarkerIcon != null) {
      final iconPNG = await capturePng(osmWebFlutterState.dynamicMarkerKey!);
      icon = iconPNG.convertToString();
      final size = osmWebFlutterState.dynamicMarkerKey?.currentContext?.size;
      iconSize = size.toSizeJS();
    }
    await interop
        .changeMarker(
          mapIdMixin.toJS,
          oldLocation.toGeoJS(),
          newLocation.toGeoJS(),
          icon?.toJS,
          iconSize,
          (angle != null ? (angle * (180 / pi)).toJS : null),
          iconAnchor?.toAnchorJS,
        )
        .toDart;
  });
}