<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=9de88a718781910c9a1c81230827d1ce&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
<title>searchNearby</title>
<style>
*{
padding: 0;
margin: 0;
list-style: none;
}
#container{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#searchNode{
position: absolute;
z-index: 9;
width: 300px;
height: 100px;
background: white;
text-align: center;
padding-top: 20px;
}
#setCenterNode{
position: absolute;
z-index: 9;
width: 300px;
background: white;
top: 100px;
}
</style>
</head>
<body>
<div id="container"></div>
<div id="searchNode">
<input type="" name="" id="searchInput" />
<button id="btn">搜索(搜‘台子村’)</button>
</div>
<div id="setCenterNode"></div>
<script>
var map = new AMap.Map('container',{
zoom:10,
center:[116.391867,39.928682]
});
AMap.service(['AMap.PlaceSearch'],function(){
btn.onclick = function(){
new AMap.PlaceSearch({
// type:'餐饮',
pageSize:5,
pageIndex:1,
city:'010',//北京城市号码010
citylimit:false,
map:map,
panel:'setCenterNode'
}).searchNearBy('',[116.391867,39.928682],500,function(status, result){
//含经纬度
console.log(status)
console.log(result)
var longitude=result.poiList.pois[0].location.lng
var latitude=result.poiList.pois[0].location.lat
alert(longitude+','+latitude)
});
}
});
</script>
</body>
</html>
本文地址:https://blog.csdn.net/weixin_42786237/article/details/107494761
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论