Abstract In complex urban environments, integrated GNSS/INS navigation faces challenges from signal degradation due to building obstructions and multipath effects. Traditional factor graph optimization methods further lack adaptability due to their dependence on accumulating historical data and static weighting. To address this, we propose a sliding-window factor graph algorithm with dynamic weight adaptation. The method confines optimization to a sliding window to reduce the influence of outdated data, while autonomously adjusting GNSS/INS factor weights based on real-time residuals, thus robustly handling observation quality fluctuations. Experimental results demonstrate that the proposed algorithm significantly improves positioning accuracy and system robustness in urban settings, outperforming conventional methods.