그 뭐냐 생일 기념 오늘은 짧게…?

오늘은 생일인 만큼 네이버 맵 리펙터링을 끝내보려한다

지금 내 코드는 처음 들어오게 되면

NaverMap(
          onMapReady: (controller) {
            context.read<NaverMapCubit>().onMapReady(controller, context);
          },
          options: const NaverMapViewOptions(
            buildingHeight: 0.0,
            symbolScale: 0.6,
            initialCameraPosition: NCameraPosition(
              target: NLatLng(36.971336282566874, 127.91767020963579),
              zoom: 12.25,
            ),
            mapType: NMapType.basic,
          ),
          //클로스터링 옵션
          clusterOptions: NaverMapClusteringOptions(
          target: NLatLng(36.971336282566874, 127.91767020963579),

요기로 카메라가 이동한다.

근데 지금

  //--------------------------------
  // 현재 위치 버튼 클릭시 현재 위치로 이동//
  //--------------------------------
  Future<void> updateMapToCurrentPosition() async {
    try {
      // gps 서비스 활성화 여부 확인
      final gpsService = await _locationService.checkGpsService();

      if (gpsService) {
        //위치 권한 확인
        final permission = await _locationService.checkLocationPermission();

        if (permission || gpsService) {
          final currentLocation = await _locationService.getCurrentLocation();
          emit(state.copyWith(currentLocation: currentLocation));

          // 지도를 현재 위치로 이동
          await state.mapController?.updateCamera(
            NCameraUpdate.withParams(
              target: const NLatLng(36.971336282566874, 127.91767020963579),
              zoom: 12.25,

              // NLatLng(
              //   state.currentLocation.latitude,
              //   state.currentLocation.longitude,
              // ),
              // zoom: 14
            )..setAnimation(duration: const Duration(milliseconds: 500)),
          );

요 함수 때문에 내 위치로 화면이 이동하게 된다.. 정리해보자 나는 처음에 지도에 내 위치를 표시하기를 희망하지만? 위치를 표시하면 내 위치로 화면이 이동된다 그 이유는 네이버 맵이 초기화 되었을 때.

  // 네이버 맵 초기화
  Future<void> onMapReady(
      NaverMapController controller, BuildContext context) async {
    emit(state.copyWith(mapController: controller));
    await _getNaverMapData();
    await _getNaverMapCategory();
    if (context.mounted) {
      await _addMarkers(context);
    }

    await Future.delayed(const Duration(seconds: 2));

    emit(state.copyWith(
      screenState: ScreenState.loaded,
    ));
    updateMapToCurrentPosition();
  }

updateMapToCurrentPosition 요 함수를 실행하기 때문에

그렇다면 실행을 해 내 위치가 화면에 보이지만 화면은

              target: NLatLng(36.971336282566874, 127.91767020963579),

여기를 바라보게 하는 방법은 어떤 방법이 있을까?

아! 방법을 찾았다 고민 시간 2분

정말 간단했다

함수를 2개로 나뉘어 1개는 네이버 맵 위젯이 실행시, 즉 cubit이 실행되는 시점 사용자의 위치를 받아오기만하고