<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo3</title>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=0bcfd2ed49ad1e3bb13961bacb6a7ca8"></script>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
#container{
width:100%;
height:100%;
position: absolute;
left: 0;
right: 0;
}
.control{
width: 320px;
height: 300px;
background-color: #fff;
z-index:99;
position:fixed;
left: 40px;
top: 40px;
padding: 10px;
}
.control .title{
width:100%;
text-align: center;
font-size: 25px;
color:#000;
font-weight:bold;
}
.control div{
width:100%;
margin-top: 10px;
height: 30px;
}
.control span{
display: inline-block;
width: 100px;
text-align: right;
}
.control input{
width: 100px;
margin-left: 10px;
}
.control button{
width: 50px;
height: 30px;
border: none;
border-radius:5px;
margin-left: 10px;
background-color: lightblue;
}
#limitbtn{
width: 100px;
height: 30px;
background-color: #f5f2fa;
}
.control .location #locationvalue{
width: 40px;
}
.control .location{
font-size: 10px;
width: 180px;
position: absolute;
bottom:5px;
right: 5px;
}
</style>
</head>
<body>
<div class="control">
<div class="title">工具栏</div>
<div class="cityNode"><span>搜索城市</span><input type="text" id="cityValue"><button id="citybtn">确定</button></div>
<div class="zoomNode"><span>设置显示级别</span><input type="text" id="zoomValue"><button id="zoombtn">确定</button></div>
<div class="button"><span> </span><button id="limitbtn">解除限制范围</button></div>
<div class="location">当前所在省/直辖市:<span id="locationvalue"></span></div>
</div>
<div id="container">
</div>
<script>
var map = new AMap.Map("container");
var myBounds = new AMap.Bounds([116.22422,39.813285],[116.567542,39.997639]);
var limitbln = true;
map.setBounds(myBounds);
map.setLimitBounds(myBounds);
map.getCity(function(info){
locationvalue.innerHTML = info.province;
});
citybtn.onclick = function(){
if(cityValue.value == ""){
return;
}
map.setCity(cityVal