SuperMap超图的热力图

来源:互联网 发布:长春工业大学网络 编辑:程序博客网 时间:2024/04/30 13:33

1:首先导入SuperMap.Include.js    

      <script src="assets/superMap/SuperMap.Include.js"></script>

2:js中添加超图图层

      GisUtil.init = function()
{
var bgrounddiv = $("#dituContent");
map = new SuperMap.Map("dituContent", {
allOverlays : true,
controls : [ new SuperMap.Control.Navigation({
dragPanOptions : {
enableKinetic : true
}
})]
});

map.addControl(new SuperMap.Control.ScaleLine());


//初始化复杂缩放控件类
panzoombar = new SuperMap.Control.PanZoomBar();
// 是否固定缩放级别为[0,16]之间的整数,默认为false
panzoombar.forceFixedZoomLevel = true;
//是否显示滑动条,默认值为false
panzoombar.showSlider = true;
/*点击箭头移动地图时,所移动的距离占总距离(上下移动的总距离为高度,左右移动的总距离为宽度)
的百分比,默认为null。 例如:如果slideRatio 设为0.5, 则垂直上移地图半个地图高度.*/
panzoombar.slideRatio = 0.5;
//设置缩放条滑块的高度,默认为11
panzoombar.zoomStopHeight = 5;
//设置缩放条滑块的宽度,默认为13
panzoombar.zoomStopWidth = 9;
map.addControl(panzoombar);
map.addControl(panzoombar,new SuperMap.Pixel(1800,700));



//添加热力图部分
heatMapLayer = new SuperMap.Layer.HeatMapLayer(
                       "heatMap",
                       {
                           "radius":45,
                           "featureWeight":"value",
                           "featureRadius":"geoRadius"
                       }
               );

gislayer = new SuperMap.Layer.TiledDynamicRESTLayer(
"sldtLayer", url, null, {
maxResolution : "auto",
scales : scales
});
gislayer.visibility = true;
gislayer.events.on({
"layerInitialized" : function() {
map.addLayers([ gislayer,heatMapLayer ]);
map.setCenter(
new SuperMap.LonLat(120.184572, 33.375925), 5);
}
});
//监控超图比例大小
map.events.on({
"zoomend" : function() {
findTaxi();
}
});

};

function findTaxi(){
if(map.getZoom()>7){

                        //执行方法

                     addDataTaxi(taxiGPSInfo,flag,k);

                   }else{

                    //清除热力图

                    heatMapLayer.removeAllFeatures();

                   }

       }

3:取数据添加热力图

function addDataTaxi(taxiGPSInfo,flag,num)
{
   var size = new SuperMap.Size(40,40);
   var offset = new SuperMap.Pixel(-(size.w/2), -size.h);
   var icon = new SuperMap.Icon('assets/images/czc2.png', size, offset);
   // 添加图层内各个标记
            marker =new SuperMap.Marker(new SuperMap.LonLat(taxiGPSInfo['jd'], taxiGPSInfo['wd']),icon) ;
           marker.sm_capital = taxiGPSInfo['xm'];
        
        
        
         if(flag){
        czclayer.addMarker(marker);
        map.addLayers([czclayer]);
        //添加监听
      marker.events.on({"click":function(e) {
     
      //组织需要嵌入的HTML字符串表达
     var contentHTML = "**********************";
  // 图标经纬度
         var  lonLat = new SuperMap.LonLat(taxiGPSInfo['jd'], taxiGPSInfo['wd'])
         var popwin = new SuperMap.Popup.Anchored('spdPopWin',
         lonLat,
         new SuperMap.Size(325,70),
         contentHTML,
         null,
         true,
          null);


          if(popwin) {map.removePopup(popwin);}
          czcPopup = popwin;
          map.addPopup(popwin,true);
      }});
         
         }else{
       var radius = '50';
       heatMapLayer.radius = radius
       heatPoints[num] = new SuperMap.Feature.Vector(
               new SuperMap.Geometry.Point(
               taxiGPSInfo['jd'],
               taxiGPSInfo['wd']
               ),
               {
//                    "value":Math.random()*9,
                   "value":4.32215,
                   "geoRadius":null
               }
       );
       heatMapLayer.featureWeight = "value";
         }
       
     
        
   
}


0 0
原创粉丝点击