欢迎各位兄弟 发布技术文章
这里的技术是共享的
1)公交1
http://www.aaa.com/ditu_gongjiao.php?start=起点&end=终点
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
#l-map{height:500px;width:100%;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=oTjk2vH"></script>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>根据起终点名称查询公交换乘</title>
</head>
<body>
<div id="l-map"></div>
<div id="driving_way">
<input type="text" name="start" value="<?php print $_GET['start'] ?>">
<input type="text" name="end" value="<?php print $_GET['end'] ?>">
<input type="button" id="result" value="查询"/>
</div>
</body>
</html>
<script type="text/javascript">
function search_gongjiao()
{
map.clearOverlays();
var i=0;
var start = $("[name='start']").val();
var end = $("[name='end']").val();
search(start,end,routePolicy[i]);
function search(start,end,route){
transit.setPolicy(route);
transit.search(start,end);
}
}
// 百度地图API功能
var map = new BMap.Map("l-map");
map.centerAndZoom(new BMap.Point(120.5369,31.187313), 14);
map.setCurrentCity("苏州");
var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
var transit = new BMap.TransitRoute(map, {
renderOptions: {map: map},
policy: 0
});
$("#result").click(function(){
search_gongjiao()
});
search_gongjiao()
</script>
效果图
2)驾车1
http://www.aaa.com/ditu_jiache.php?start=起点&end=终点
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
#allmap{height:500px;width:100%;}
#r-result,#r-result table{width:100%;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=oTj"></script>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>根据起终点名称驾车导航</title>
</head>
<body>
<div id="allmap"></div>
<div id="driving_way">
<input type="text" name="start" value="<?php print $_GET['start'] ?>">
<input type="text" name="end" value="<?php print $_GET['end'] ?>">
<input type="button" id="result" value="查询"/>
</div>
<div id="r-result"></div>
</body>
</html>
<script type="text/javascript">
function search_jiache()
{
map.clearOverlays();
var i=0;
var start = $("[name='start']").val();
var end = $("[name='end']").val();
search(start,end,routePolicy[i]);
function search(start,end,route){
var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true},policy: route});
driving.search(start,end);
}
}
// 百度地图API功能
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(120.5369,31.187313), 14);
map.setCurrentCity("苏州");
//三种驾车策略:最少时间,最短距离,避开高速
var routePolicy = [BMAP_DRIVING_POLICY_LEAST_TIME,BMAP_DRIVING_POLICY_LEAST_DISTANCE,BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];
$("#result").click(function(){
search_jiache()
});
search_jiache()
</script>
效果图
3)公交2
http://www.bbb.com/baidu_car_search.php?start=起点&end=终点
<?php
$start = $_GET['start'];
$end = $_GET['end'];
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
#l-map{height:700px;width:100%;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=oTjk"></script>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>根据起终点名称查询公交换乘</title>
</head>
<body>
<div id="l-map"></div>
<div id="driving_way">
<select>
<option value="0">最少时间</option>
<option value="1">最少换乘</option>
<option value="2">最少步行</option>
<option value="3">不乘地铁</option>
</select>
<input type="button" id="result" value="查询"/>
</div>
</body>
</html>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("l-map");
map.centerAndZoom(new BMap.Point(120.598237, 31.298642), 11);
var start = "<?php echo $start ?>";
var end = "<?php echo $end ?>";
var routePolicy = [BMAP_TRANSIT_POLICY_LEAST_TIME,BMAP_TRANSIT_POLICY_LEAST_TRANSFER,BMAP_TRANSIT_POLICY_LEAST_WALKING,BMAP_TRANSIT_POLICY_AVOID_SUBWAYS];
var transit = new BMap.TransitRoute(map, {
renderOptions: {map: map},
policy: 0
});
$("#result").click(function(){
map.clearOverlays();
var i=$("#driving_way select").val();
search(start,end,routePolicy[i]);
function search(start,end,route){
transit.setPolicy(route);
transit.search(start,end);
}
});
</script>
效果图
4)驾车2
http://www.bbb.com/baidu_car_search.php?start=起点&end=终点
<?php
$start = $_GET['start'];
$end = $_GET['end'];
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
#allmap{height:700px;width:100%;}
#r-result,#r-result table{width:100%;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=oTjk"></script>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>根据起终点名称驾车导航</title>
</head>
<body>
<div id="allmap"></div>
<div id="driving_way">
<select>
<option value="0">最少时间</option>
<option value="1">最短距离</option>
<option value="2">避开高速</option>
</select>
<input type="button" id="result" value="查询"/>
</div>
<div id="r-result"></div>
</body>
</html>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("allmap");
var start = "<?php echo $start ?>";
var end = "<?php echo $end ?>";
map.centerAndZoom(new BMap.Point(120.598237, 31.298642), 11);
//三种驾车策略:最少时间,最短距离,避开高速
var routePolicy = [BMAP_DRIVING_POLICY_LEAST_TIME,BMAP_DRIVING_POLICY_LEAST_DISTANCE,BMAP_DRIVING_POLICY_AVOID_HIGHWAYS];
$("#result").click(function(){
map.clearOverlays();
var i=$("#driving_way select").val();
search(start,end,routePolicy[i]);
function search(start,end,route){
var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true},policy: route});
driving.search(start,end);
}
});
</script>
效果图