为什么我没反应呀? 也没有报错
来源:4-8 地图搜索与poi结合(4)
慕侠9181480
2019-08-28 14:48:20
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=5247135ee7e3e0eb2dcd168a621c6737"></script>
<style>
* {
padding: 0;
margin: 0;
list-style-type: none;
}
#container {
width: 80vw;
height: 90vh;
margin-top: 18px;
margin-left: 8px;
box-shadow: 0 0 3px black;
}
#whiteBox {width:280px; background-color: white; position: absolute; top: 38px; right: 8px; box-shadow: 0 0 5px black}
.searchNode{width: 230px; background: white; position: absolute; top: 8px; right: 8px;}
</style>
</head>
<body>
<div id="container"></div>
<div class="searchNode">
<input type="text" id="searchText">
<button id="searchBtn">搜索</button>
</div>
<div id="whiteBox"></div>
<script>
//加载图片要使用服务器 node node.js
var myMap = new AMap.Map("container",{
zoom:8,
center:[116,39]
});
//searchNearBy 设定范围
AMap.service(["AMap.PlaceSearch"], function(){
searchBtn.onclick = function(){
new AMap.PlaceSearch({
city:'010',
panel:'whiteBox', //放在哪个元素下
map:myMap, //要展示的地图
pageSize:5, //一页显示几个
type:'住宿', //一开始显示第几页
}).searchNearBy('', [116,39], 1000, function(){});
}
})
</script>
</body>
</html>
1回答
同学你好!
应该是[116,39], 1000范围内没有住宿这个类型,建议同学修改下经纬度(比较详细的经纬度)
如下:


如果帮助到了你,欢迎采纳,祝学习愉快~
相似问题