百度地图 在加载过程中,根据回调函数结果中第一个点设置为中心点
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script> <title>24.1在加载过程中,根据回调函数结果中第一个点设置为中心点</title> </head> <body> <div class="wrapper"> <div class="container clearfix"> <div class="clearfix"> <div style="clear: both;"> <div style="float: left; width: 500px; height: 340px; border: 1px solid gray" id="container"> </div> </div> </div> </div> </div> </body> </html> <script type="text/javascript"> var map = new BMap.Map("container"); map.centerAndZoom(new BMap.Point(116.404, 39.915), 16); function myFun() { var point = local.getResults().getPoi(0).point; map.centerAndZoom(point, 18); } var local = new BMap.LocalSearch(map, { onSearchComplete: myFun }); local.search("酒仙桥"); </script>