In order to effectively control a legged robot and navigate across diverse terrains, it is essential to perceive the robot's surrounding terrain. Previous approaches involved generating a height map by projecting a depth image captured by a camera mounted on the robot, using odometry information to determine the robot's pose. However, this method often resulted in inconsistencies between the generated height map and the actual terrain due to odometry drift or depth image inaccuracies. To address this issue, I introduce CIA-SLAM (Contact Information-Aided SLAM), a novel SLAM system that leverages foot contact information to obtain a precise height map relative to the robot. CIA-SLAM builds upon the foundation of feature-based SLAM, which optimizes robot poses and feature points, and extends it to optimize the height map as well. In the process of bundle adjustment, CIA-SLAM jointly optimizes robot poses, feature points, and the height map, incorporating additional constraints from the original feature-based SLAM approach. These constraints include foot contact information and the projection of depth images onto the height map. By integrating these supplementary cues, CIA-SLAM enhances the accuracy of the height map, enabling more precise control and navigation for legged robots across diverse terrains.