Achieving higher accuracy and robustness stands as the central objective in the navigation field. In complex urban environments, the integrity of GNSS faces huge challenges and the performance of integrated navigation systems can be significantly affected. As the proportion of faulty measurements rises, it can result in both missed alarms and false positives. In this paper, a robust method based on factor graph is proposed to improve the performance of integrated navigation systems. We propose a detection method based on multi-conditional analysis to determine whether GNSS is anomalous or not. Moreover, the optimal weight of GNSS measurement is estimated under anomalous conditions to mitigate the impact of GNSS outliers. The proposed method is evaluated through real-world road tests, and the results show the positioning accuracy of the proposed method is improved by more than 60% and the missed alarm rate is reduced by 80% compared with the traditional algorithms.