Due to the rapid growth in ride-hailing services and the steady expansion of urban rail transit networks, understanding the complex interaction between the two is important. Most existing studies only focus on the overall competition and cooperation effects. Few scholars discuss local spatial differences and how the built environment works in detail. To investigate the spatial heterogeneity of built environment factors between the ride-hailing and the subway systems by situation and location, our study categorizes 3.71 million ride-hailing trips into three types: Proximal-to-Station Trip (PST), Medial-to-Station Trip (MST), and Distal-to-Station Trip (DST). We employed the values of built environment factors per grid as independent variables, and the grid-based volume of each ride-hailing trip category (PST, MST, DST) as the dependent variable. Additionally, we conducted analysis mainly with the multi-scale geographically weighted regression model (MGWR). We found that ride-hailing trips and subway trips have competition, cooperation, or complementarity relationships, which depend on trip purposes and public transit accessibility. Besides, we think that this relationship relies on the built environment, and it also shows clear spatial heterogeneity. The impact of different built environment factors has significant variation and spatial heterogeneity: Catering, Shop, and Bus Stop continuously trigger the demand for ride-hailing services, while Residence generally reduces the use. In PST, Enterprise, Medical, and Residence inhibit ride-hailing due to the high subway accessibility. In DST, these functions conversely boost ride-hailing usage due to limited bus coverage. These findings provide crucial insights for smart transportation management, multi-modal, and location-specific strategies to boost sustainable urban transportation development.