每日双人总结——web地铁查询
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!--重要meta, 必须!--> <meta name="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,shrink-to-fit=no" /> <title>SUBWAY</title> </head> <body> <div id="mybox"></div> <script src="https://webapi.amap.com/subway?v=1.0&key=c72369c85b8879d406cf53e77fc4d379&callback=cbk"></script> <script type="text/javascript"> window.cbk = function() { var mySubway = subway("mybox", { adcode: 1100, theme: "colorful", client: 0, doubleclick: { switch: true } }); //地铁加载完成,执行complete事件 mySubway.event.on("subway.complete", function(ev, info) { var id = info.id; }); //点击站点,显示此站点的信息窗体 mySubway.event.on("station.touch", function(ev, info) { var id = info.id; mySubway.stopAnimation(); mySubway.addInfoWindow(id, {}); var center = mySubway.getStCenter(id); mySubway.setCenter(center); }); //点击线路名,高亮此线路 mySubway.event.on("lineName.touch", function(ev, info) { mySubway.showLine(info.id); var select_obj = qs('#g-select'); mySubway.setFitView(select_obj); var center = mySubway.getSelectedLineCenter(); mySubway.setCenter(center); }); //点击空白, 关闭infowindow mySubway.event.on("subway.touch", function() { mySubway.clearInfoWindow(); }); //设置起点 mySubway.event.on("staratStation.touch", function(ev, info) { mySubway.stopAnimation(); mySubway.clearInfoWindow(); mySubway.setStart(info.id, {}); startInfo = info; route(); }); //设置终点 mySubway.event.on("endStation.touch", function(ev, info) { mySubway.stopAnimation(); mySubway.clearInfoWindow(); mySubway.setEnd(info.id, {}); endInfo = info; route(); }); //路线规划 var startInfo = {}, endInfo = {}; function route() { if (startInfo.id && endInfo.id) { mySubway.route(startInfo.id, endInfo.id, {}); startInfo = {}; endInfo = {}; } } }; </script> </body> </html>
调用高德地图的官方api接口实现线路查询,最短路线计算等
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人