首页 / 浏览问题 / 云GIS / 问题详情
isever热力图怎么显示,在线等
77EXP 2017年08月30日
我按照官方代码例子改了下代码,只把地图服务改了,但是改了测试下热力图没有显示出来,是怎么回事。

1个回答

你好 需要贴下你的代码看下
7EXP 2017年08月30日
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>热点图</title>
<style type="text/css">
body{
margin: 0;
overflow: hidden;
background: #fff;
}
#map{
position: relative;
height: 520px;
border:1px solid #3473b7;
}
#toolbar {
position: relative;
padding-top: 5px;
padding-bottom: 10px;
}
</style>
<link href='./css/bootstrap.min.css' rel='stylesheet' />
<link href='./css/bootstrap-responsive.min.css' rel='stylesheet' />
<script src='libs/SuperMap.Include.js'></script>
<script type="text/javascript">
    var host = "http://localhost:8090" ;
    var map, layer, heatMapLayer,
    url = host + "/iserver/services/map-world/rest/maps/World";
    function init() {
        if (!document.createElement('canvas').getContext) {
            alert('您的浏览器不支持 canvas,请升级');
            return;
        }

        map = new SuperMap.Map("map", {
            controls: [
            new SuperMap.Control.ScaleLine(),
            new SuperMap.Control.Zoom(),
            new SuperMap.Control.Navigation({
                dragPanOptions: {
                    enableKinetic: true
                }
            })]
        });
        map.addControl(new SuperMap.Control.MousePosition());
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, { transparent: true, cacheEnabled: true }, { maxResolution: "auto" });
        heatMapLayer = new SuperMap.Layer.HeatMapLayer(
        "heatMap",
        {
            "radius": 45,
            "featureWeight": "value",
            "featureRadius": "geoRadius"
        }
        );
        layer.events.on({ "layerInitialized": addLayer });
    }

    function addLayer() {
        map.addLayers([layer, heatMapLayer]);
        map.setCenter(new SuperMap.LonLat(0, 0), 0);
    }
    function createHeatPoints() {
        clearHeatPoints();
        var heatPoints = [];
        var num = parseInt(document.getElementById('heatNums').value);
        var radius = parseInt(document.getElementById('heatradius').value);
        //var useGeoRadius = "checked" == $('#useGeoRadius').attr('checked');
        var unit = document.getElementById("radiusUnit").value,
        useGeoRadius = false;
        if ("degree" == unit) {
            useGeoRadius = true;
        }
        heatMapLayer.radius = radius
        for (var i = 0; i < num; i++) {
            heatPoints[i] = new SuperMap.Feature.Vector(
            new SuperMap.Geometry.Point(
            Math.random() * 360 - 180,
            Math.random() * 180 - 90
            ),
            {
                "value": Math.random() * 9,
                "geoRadius": useGeoRadius ? radius : null
            }
            );
        }
        heatMapLayer.addFeatures(heatPoints);
    }

    function clearHeatPoints() {
        heatMapLayer.removeAllFeatures();
    }
</script>
</head>
<body onload="init()">
<div id="toolbar">
<span>热点数量:</span>
<input type='text' style='width:50px;height: 30px' id='heatNums' value='200'/>
<span>热点半径:</span>
<input type='text' style='width:30px;height: 30px' value='50' id='heatradius'/>
<select style='width:70px' id='radiusUnit'><option value='px'>px</option><option value ='degree'>degree</option></select>
<input type="button" class="btn" value="渲染热点" style="margin-bottom: 10px" onclick="createHeatPoints()" />
<input type="button" class="btn" value="清除" style="margin-bottom: 10px" onclick="clearHeatPoints()" />
</div>
<div id="map"></div>
</body>
</html>

都是官方的,我只改了下服务那

地图能加载显示吗
能,是不是还得改其他地方呢,我就把地图服务改了下
可以F12看下有啥错误提示
没有提示错误,是不是根热点半径设置有关系?
...