百度地圖加載海量點


//初始化坐標點
function initCoordinateInfo(){
  $.ajax({
    url: "url",
    async: true,
    method: 'GET',
    dataType: "json",
    cache: false,
    success: function (result) {
      // console.log(map.getZoom());
//顯示海量點
      if (map.getZoom() <= 12) {
  //海量點數據
points = [];
// 添加海量點數據
for(var i = 0; i < result.data.length; i++){
          var p =new BMap.Point(result.data[i].mapX, result.data[i].mapY);
            p.type= result.data[i].type;
            points.push(p)
}
mapOverlay();
      } else {
  map.clearOverlays();
  var allOverlay = map.getOverlays();
        for (var i = 0; i < allOverlay.length; i++) {
   //console.log(allOverlay[i]);
  if (allOverlay[i].__proto__.wQ == "PointCollection") {
    map.removeOverlay(allOverlay[i]);
  }
  }
}
    }
  })
}

//把海量坐標繪制到地圖上
function mapOverlay11(type) {
  //坐標點樣式
  var options = {size: BMAP_POINT_SIZE_SMALL, shape: BMAP_POINT_SHAPE_CIRCLE, color: '#0000EE'}
  //創建pointCollection
  pointCollection = new BMap.PointCollection(points, options);
  //添加點擊控件
  pointCollection.addEventListener("click",function(e){
    var content = "這是彈窗信息"
    var point = new BMap.Point(e.point.lng, e.point.lat);
    var opts = {
      width: 250, // 信息窗口寬度
      height: 70, // 信息窗口高度
      //title:"", // 信息窗口標題
      //enableMessage: false,// 設置允許信息窗發送短息
    }
    var infoWindow = new BMap.InfoWindow(content); // 創建信息窗口對象
    map.openInfoWindow(infoWindow,point); //開啟信息窗口
  });
  // 添加Overlay
  map.addOverlay(pointCollection);
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM