打开
替换为以下源码, 点击运行
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>线路规划</title>
<script type="text/javascript" src="//api.map.baidu.com/api?type=subway&v=1.0&ak=您的密钥"></script>
<style type="text/css">
#container{height:100%}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
var subwayCityName = '深圳';
var list = BMapSub.SubwayCitiesList;
var subwaycity = null;
for (var i = 0; i < list.length; i++) {
if (list[i].name === subwayCityName) {
subwaycity = list[i];
break;
}
}
// 获取北京地铁数据-初始化地铁图
var subway = new BMapSub.Subway('container', subwaycity.citycode);
var drct ;
subway.addEventListener('subwayloaded', function() {
drct = new BMapSub.Direction(subway);
});
</script>
</body>
</html>
F12 , Ctrl+P, 打开名为 " api?type=subwayXXX... " 的文件
点击格式化, 定位到8330行,右键, 加入条件断点, 内容为
console.log( json.result.s_query ,json.result.e_query, Math.round(json.content[0].exts[0].time/60) )
再在控制台切换到运行container,如图, 再运行:
Object.keys(subway.subwayData.stationHash).forEach(end =>drct.search('布吉', end));
可得出结果: