标签:
html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<title>地图</title>
<link rel="stylesheet" href="personal.css"/>
<script type="text/javascript" src="js/jquery-2.2.2.min.js"></script>
<script type="text/javascript"
src="http://api.map.baidu.com/api?v=2.0&ak=fofkFVBIXPsmyqpaXrEnyGLbG2CQMTMG"></script>
<style type="text/css">
#l-map {
width: 590px;
height: 382px;
margin: 20px auto 0;
border: 1px solid #DCDCDC;
}
#r-result {
width: 590px;
height: 382px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="l-map"></div>
<div id="r-result"></div>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("l-map"); // 创建Map实例
map.centerAndZoom(new BMap.Point(117.27, 31.86), 11);
var myKeys = ["菜市场,农贸市场"];
var local = new BMap.LocalSearch(map, {
renderOptions: {
map: map,
panel: "r-result"
},
pageCapacity: 5
});
local.searchInBounds(myKeys, map.getBounds());
</script>
</body>
</html>
result:
标签:
原文地址:http://www.cnblogs.com/theWayToAce/p/5450447.html