initPositionMap method

  1. @override
Future<void> initPositionMap({
  1. GeoPoint? initPosition,
  2. UserTrackingOption? userPositionOption,
  3. bool useExternalTracking = false,
})

Implementation

@override
Future<void> initPositionMap({
  GeoPoint? initPosition,
  UserTrackingOption? userPositionOption,
  bool useExternalTracking = false,
}) async {
  interop.setUpMap(mapIdMixin.toJS);
  assert((initPosition != null) ^ (userPositionOption != null));
  if (osmWebFlutterState.widget.controller.customTile != null) {
    await changeTileLayer(
      tileLayer: osmWebFlutterState.widget.controller.customTile,
    );
  }

  if (osmWebFlutterState.widget.staticIconGlobalKeys.isNotEmpty) {
    var keys = osmWebFlutterState.widget.staticIconGlobalKeys;
    keys.removeWhere((key, value) =>
        osmWebFlutterState.widget.staticPoints
            .firstWhere((element) => element.id == key)
            .markerIcon ==
        null);
    keys.forEach((id, key) {
      markerIconsStaticPositions(id, key);
    });
  }
  if (osmWebFlutterState.widget.roadConfiguration != null) {
    defaultRoadOption = osmWebFlutterState.widget.roadConfiguration!;
  }

  /// change user person Icon and arrow Icon
  if (osmWebFlutterState.widget.userLocationMarker != null) {
    await customUserLocationMarker(
      osmWebFlutterState.personIconMarkerKey,
      osmWebFlutterState.arrowDirectionMarkerKey,
    );
  }

  await configureZoomMap(
    osmWebFlutterState.widget.minZoomLevel,
    osmWebFlutterState.widget.maxZoomLevel,
    osmWebFlutterState.widget.stepZoom,
    osmWebFlutterState.widget.initZoom,
  );

  GeoPoint? initLocation = initPosition;

  if (userPositionOption != null && initLocation == null) {
    initLocation = await myLocation();
  }
  await initLocationMap(initLocation!);

  if (osmWebFlutterState.widget.staticPoints.isNotEmpty) {
    for (var ele in osmWebFlutterState.widget.staticPoints) {
      setStaticPosition(ele.geoPoints, ele.id);
    }
  }
  if (userPositionOption != null && userPositionOption.enableTracking) {
    switch (useExternalTracking) {
      case true:
        await startLocationUpdating();
        break;
      case false:
        await currentLocation();
        await enableTracking(
          enableStopFollow: userPositionOption.unFollowUser,
        );
        break;
    }
  }
}