<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,#allmap {width: 300px;height: 300px;overflow: hidden;margin:0;}
#goods {
height: 300px;
width: 300px;
margin-right: auto;
margin-left: auto;
}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=70E22E63d13b99e4b96f53185676c152"></script>
<title>根据起终点名称驾车导航</title>
</head>
<body><div id="allmap"></div>
<div id="goods">
请输入起始地址:<input type="text" id="start1" name="start1">
请输入目的地址:<input type="text" id="end1" name="end1">
<input type="button" value="确定" id="queding">
</div>

<script type="text/javascript">// 百度地图API功能
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(108.33, 22.84), 14);
var transit = new BMap.TransitRoute(map, {
  renderOptions: {map: map}
}); document.getElementById("queding").onclick=searchit;
function searchit(){
startPoint=document.getElementById("start1");
endPoint=document.getElementById("end1");
transit.search(startPoint.value.replace('^\s*|\s*$',''),endPoint.value.replace('^\s*|\s*$',''));
}
</script>
</body>
</html>

解决方案 »

  1.   

    被你的地图挡住了<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, #allmap
            {
                width: 300px;
                height: 300px;
                overflow: hidden;
                margin: 0;
                display:inline;
            }
            #goods
            {
                height: 300px;
                width: 300px;
                margin-right: auto;
                margin-left: 300px;
            }
        </style>
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=70E22E63d13b99e4b96f53185676c152"></script>
        <title>根据起终点名称驾车导航</title>
    </head>
    <body>
        <div id="allmap">
        </div>
        <div id="goods">
            请输入起始地址:<input type="text" id="start1" name="start1"/>
            请输入目的地址:<input type="text" id="end1" name="end1"/>
            <input type="button" value="确定" id="queding"/>
        </div>
        <script type="text/javascript">        // 百度地图API功能
            var map = new BMap.Map("allmap");
            map.centerAndZoom(new BMap.Point(108.33, 22.84), 14);
            var transit = new BMap.TransitRoute(map, {
                renderOptions: { map: map }
            });        document.getElementById("queding").onclick = searchit;
            function searchit() {
                startPoint = document.getElementById("start1");
                endPoint = document.getElementById("end1");
                transit.search(startPoint.value.replace('^\s*|\s*$', ''), endPoint.value.replace('^\s*|\s*$', ''));
            }
        </script>
    </body>
    </html>