changeMarker method

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

Implementation

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