眉山人论坛公交服务站 (眉山人论坛app)

成都洗浴 06-30 阅读:15 评论:0

眉山人论坛公交服务站

实时查询公交车信息,出行更方便。

    眉山人论坛公交服务站 (眉山人论坛app)
  • 101路 运营中
  • 102路 即将进站
  • response.json()).then(data => {// 循环公交路线数据data.busLines.forEach(busLine => {// 创建公交路线路径var path = [];busLine.coordinates.forEach(coordinate => {path.push({lat: coordinate[0], lng: coordinate[1]});});// 创建公交路线多边形var polygon = new google.maps.Polygon({path: path,strokeColor: '009900',strokeOpacity: 0.8,strokeWeight: 3,fillColor: '009900',fillOpacity: 0.2});// 添加公交路线多边形到地图polygon.setMap(map);});}).catch(error => {console.error('Error fetching bus line data: ', error);});}// 搜索公交线路document.getElementById('search-form').addEventListener('submit', function(e) {e.preventDefault();// 获取用户输入的公交线路号var busNum = document.getElementById('search-input').value;// 查找公交线路数据fetch('bus_lines.json').then(response => response.json()).then(data => {var busLine = data.busLines.find(busLine => busLine.num === busNum);// 如果找到公交线路,则在地图上显示if (busLine) {var path = [];busLine.coordinates.forEach(coordinate => {path.push({lat: coordinate[0], lng: coordinate[1]});});var polygon = new google.maps.Polygon({path: path,strokeColor: '009900',strokeOpacity: 0.8,strokeWeight: 3,fillColor: '009900',fillOpacity: 0.2});polygon.setMap(map);} else {// 如果未找到公交线路,则提示用户alert('未找到该公交线路。');}}).catch(error => {console.error('Error fetching bus line data: ', error);});});// 初始化地图时调用 initMap 函数window.onload = function() {initMap();};
版权声明

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