老师,我导航出来的起点和终点位置怎么和我输入的不一致

来源:8-1 驾车路线

慕仙本仙_

2020-04-08 21:23:44

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title></title>

<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=a2d5b747b47d09c45689c88ad49fe29a&plugin=AMap.Driving,AMap.Autocomplete"></script>

<style>

*{

margin: 0;

padding:0;

list-style: none;

cursor: pointer;

}

#container{

width:100%;

height:100%;

position:absolute;

left:0;

top:0;

}

#panel{

position:fixed;

background:#fff;

top:10px;

right:10px;

width:280px;

}

#search{

width:200px;

height:100px;

position:absolute;

left:10px;

top:10px;

background:#FFF;

}

.amap-icon img{

width:25px;

height:34px

}

</style>

</head>

<body>

<div id="container"></div> 

<div id="panel"></div>

<div id="search">

起点:<input type="text" id="startNode"/><br />

终点:<input type="text" id="endNode"/><br />

<button id="btn">开始导航</button>

</div>

<script type="text/javascript">

//var inputText=document.getElementById('input').value;

var map=new AMap.Map('container',{

zoom:11,

center:[108.940275,34.274717]

});

new AMap.Autocomplete({

input:'startNode'

});

new AMap.Autocomplete({

input:'endNode'

});

btn.onclick=function(){

new AMap.Driving({

map:map,

panel:'panel'

}).search([

{keyWord:startNode.value,city:'西安'},

{keyWord:endNode.value,city:'西安'}

],function(status,data){

console.log(data);

});

}

</script>

</body>

</html>


写回答

2回答

好帮手慕码

2020-04-09

同学你好,是因为keyword写错了,w是小写:

http://img.mukewang.com/climg/5e8e823809b4015303750136.jpg

效果:

http://img.mukewang.com/climg/5e8e825409da74da11950590.jpg

如果我的回答帮到了你,欢迎采纳,祝学习愉快~

0

慕仙本仙_

提问者

2020-04-08

行政中心(地铁站)

陕西科技大学西安校区

index.html?__hbt=1586352071912:74 {info: "OK", origin: c, destination: c, routes: Array(1), start: {…}, …}info: "OK"origin: c {Q: 34.277618, R: 108.96183100000002, lng: 108.961831, lat: 34.277618}destination: c {Q: 34.275818, R: 108.96161899999998, lng: 108.961619, lat: 34.275818}routes: [{…}]start: {id: "B001D08UZ3", name: "西安站", type: "交通设施服务;火车站;火车站", location: c, address: "环城北路44号", …}end: {id: "B001D08UZ3", name: "西安站", type: "交通设施服务;火车站;火车站", location: c, address: "环城北路44号", …}originName: "西安站"destinationName: "西安站"waypoints: []__proto__: Object

上面两行分别是控制台打印的我输入的起点和终点

下面是打印出来的data数据,为什么是西安站呐

0

0 学习 · 6815 问题

查看课程