addMarker method

  1. @override
Future<void> addMarker(
  1. GeoPoint p, {
  2. MarkerIcon? markerIcon,
  3. String? assetAnimatedIconMarker,
  4. double? angle,
  5. IconAnchor? iconAnchor,
})

addMarker

create marker int specific position without change map camera, you can rotate marker using angle and also set marker anchor using iconAnchor

p : (GeoPoint) desired location

markerIcon : (MarkerIcon) set icon of the marker

Implementation

@override
Future<void> addMarker(
  GeoPoint p, {
  MarkerIcon? markerIcon,
  String? assetAnimatedIconMarker,
  double? angle,
  IconAnchor? iconAnchor,
}) async {
  Widget? icon = markerIcon ??
      const Icon(
        Icons.location_on,
        size: 32,
        color: Colors.red,
      );
  osmWebFlutterState.widget.dynamicMarkerWidgetNotifier.value = icon;
  await Future.delayed(duration, () async {
    final icon = await capturePng(osmWebFlutterState.dynamicMarkerKey!);
    var sizeIcon = osmWebFlutterState.dynamicMarkerKey!.currentContext?.size;
    IconAnchorJS? anchor;
    if (iconAnchor != null) {
      anchor = iconAnchor.toAnchorJS;
    }
    interop.addMarker(
      mapIdMixin.toJS,
      p.toGeoJS(),
      sizeIcon.toSizeJS(),
      icon.convertToString().toJS,
      (angle != null ? (angle * (180 / pi)) : 0).toJS,
      anchor,
    );
  });
}