这个事件都没绑定是怎么回事
来源:3-12 自由编程
Ting111
2020-05-21 16:41:26
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=0f998f9551f6d07368bf11de35aae4e7"></script>
<style type="text/css">
#ditu{
height: 100%;
width: 100%;
position: absolute;
}
input{
height: 30px;
width: 80px;
position: relative;
margin: 10px 10px;
display: block;
}
button{
position: relative;
}
</style>
</head>
<body>
<div id="ditu"></div>
<input type="text" name="" id="chengshi" />
<button id='sousuo'>search</button>
<input type="text" name="" id="jibie" />
<button id="shezhi">set</button>
<script type="text/javascript">
var map=new AMap.Map('ditu');
//显示范围限制北京
var bound=new AMap.Bounds([116.22422,39.813285],[116.567542,39.997639])
map.setLimitBounds(bound);
//设置级别
shezhi.onclick=function(){
map.setZoom('jibie.value')
}
//设置城市
sousuo.onclick=function(){
map.clearLimitBounds();
map.setCity('chengshi.value');
}
</script>
</body>
</html>1回答
好帮手慕星星
2020-05-21
同学你好,事件是绑定成功的,但是两个方法中参数加了引号,变为普通字符串,没有意义,所以没有效果。参考修改:

自己再测试下,祝学习愉快!
相似问题