城市交通:获取地点经纬度

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=8G4vyBVhZCXiG4mq5GhjlPVuVvdf5YNA"></script>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <title>获取 嘉善县加油站点经纬度</title>
</head>
<body>
	<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
// // 百度地图API功能
var map = new BMap.Map("allmap");            // 创建Map实例
var mPoint = new BMap.Point(120.92716, 30.83075);  
map.enableScrollWheelZoom();
map.centerAndZoom(mPoint,11);

var ls = new BMap.LocalSearch("嘉善县");
ls.search("加油站");
ls.setPageCapacity(100)
ls.setSearchCompleteCallback(function(rs){
	console.log(ls.getResults())
    if(ls.getStatus() == BMAP_STATUS_SUCCESS){
        for(var i= 0 ; i < rs.getCurrentNumPois();i++){
            var poi = rs.getPoi(i);
            console.log(poi.title+"','"+poi.address+"','"+poi.point.lng+"','"+poi.point.lat)
        }
    }
});
</script>

猜你喜欢

转载自blog.csdn.net/qq_36336522/article/details/105941739