杭州实时地铁 (杭州实时地铁查询)

杭州耍耍 06-01 阅读:41 评论:0

站点名称:

运营时间:

换乘线路:

列车编号:

到站时间:

终点站:

杭州实时地铁 (杭州实时地铁查询)

本查询系统提供杭州地铁实时信息,数据来源:杭州地铁官方网站。

css body {font-family: Arial, sans-serif; }h1 {text-align: center; }map {width: 100%;height: 500px; }info-panel {display: flex;justify-content: space-around;align-items: center;width: 100%;height: 200px;background-color: f5f5f5; }station-info {width: 50%; }train-info {width: 50%; }p {margin-bottom: 10px; }b {font-weight: bold; } javascript // Initialize the map var map = L.map('map').setView([30.28683, 120.15603], 13);// Add the OpenStreetMap tile layer L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '© OpenStreetMap contributors' }).addTo(map);// Add the Hangzhou subway station layer L.geoJSON(stations, {pointToLayer: function(feature, latlng) {return L.marker(latlng);},onEachFeature: function(feature, layer) {layer.bindPopup(feature.properties.name);} }).addTo(map);// Add the event listener for the subway station layer map.on('click', function(e) {var station = e.layer.feature.properties;// Update the station info paneldocument.getElementById('station-info').innerHTML = `

站点名称: ${station.name}

运营时间: ${station.operation_hours}

换乘线路: ${station.interchange_lines}

`;// Get the train infogetTrainInfo(station.id); });// Function to get the train info function getTrainInfo(stationId) {var url = `${stationId}`;fetch(url).then(response => response.json()).then(data => {// Update the train info paneldocument.getElementById('train-info').innerHTML = `

列车编号: ${data.train_id}

到站时间: ${data.arrival_time}

终点站: ${data.destination}

`;}).catch(error => {console.log(error);}); }
版权声明

本文仅代表作者观点,不代表杭州桑拿立场。
本文系作者授权发表,未经许可,不得转载。