老师请检查

来源:4-7 自由编程

慕尼黑5122342

2019-12-04 18:34:07

<!DOCTYPE html>

<html>

<head>

<title></title>

<meta charset="utf-8">

<style type="text/css">

*{margin: 0;padding: 0;list-style: none;}

#container{

width:100%;

height:100%;

position:absolute;

}

#inp{

position:absolute;

z-index: 2;

width:300px;

height: 30px

}

#box{

width: 300px;

position: absolute;

top: 30px;


}

</style>

</head>

<body>

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

<div class="wk">

<input type="text" name="" id="inp">

<div id="box"></div>

</div>

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

<script type="text/javascript">

var box=document.getElementById('box');

var inp=document.getElementById('inp');

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

zoom:11,

center:[111,22]

});

var xiala=new AMap.Autocomplete({

input:'inp'

});


var sear=new AMap.PlaceSearch({

map:map,

pageSize:5,

pageIndex:1,

panel:'box'

});

AMap.event.addListener(xiala,'select',function(e){

box.style.display='block';

sear.search(e.poi.name);

});

inp.oninput=function (){

box.style.display='none';

}

</script>

</body>

</html>


写回答

1回答

好帮手慕星星

2019-12-04

同学你好,代码是正确的。继续加油,祝学习愉快~

0

0 学习 · 6815 问题

查看课程