首页 / 浏览问题 / 云GIS / 问题详情
统计专题图生成失败,临时地图集是空的
13EXP 2017年05月18日
<!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: 510px;
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 map, local, baseLayer, layersID, themeLayer,
 url = "http://localhost:8090/iserver/services/map---0--China400/rest/maps/HBMap@China400";
    function init() {
        map = new SuperMap.Map("map", { controls: [
                      new SuperMap.Control.ScaleLine(),
                      new SuperMap.Control.PanZoomBar(),
                      new SuperMap.Control.LayerSwitcher(),
                      new SuperMap.Control.Navigation({
                          dragPanOptions: {
                              enableKinetic: true
                          }
                      }),
                      ],
                      
        });
        baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("河北省专题图", url, { transparent: true, cacheEnabled: true }, { maxResolution: "auto" });
        baseLayer.events.on({ "layerInitialized": addLayer });
        map.allOverlays = true;
    }

    function addLayer() {
        map.addLayer(baseLayer);
       
        map.setCenter(new SuperMap.LonLat(13133579.91, 5012957.79), 0);
       // map.allOverlays = true;
    }
    //对 Jingjin 数据源的 BaseMap_R 数据集两个字段 Pop_Rate95 和 Pop_Rate99 制作统计专题图
    function addThemeGraph() {
        removeTheme();
        //创建统计专题图对象,ThemeGraph 必设 items。
        //专题图参数 ThemeParameters 必设 theme(即以设置好的分段专题图对象)、dataSourceName 和 datasetName
        var style1 = new SuperMap.REST.ServerStyle({
            fillForeColor: new SuperMap.REST.ServerColor(92, 73, 234),
            lineWidth: 0.1
        }),
            style2 = new SuperMap.REST.ServerStyle({
                fillForeColor: new SuperMap.REST.ServerColor(211, 111, 240),
                lineWidth: 0.1
            }),
            item1 = new SuperMap.REST.ThemeGraphItem({
                caption: "1992-1995人口增长率",
                graphExpression: "FLOWER_1995",
                uniformStyle: style1
            }),
            item2 = new SuperMap.REST.ThemeGraphItem({
                caption: "1995-1999人口增长率",
                graphExpression: "FLOWER_2000",
                uniformStyle: style2
            }),
            themeGraph = new SuperMap.REST.ThemeGraph({
                items: new Array(item1, item2),
                barWidth: 0.03,
                graduatedMode: SuperMap.REST.GraduatedMode.SQUAREROOT,
                overlapAvoided: true,
                graphAxes: new SuperMap.REST.ThemeGraphAxes({
                    axesDisplayed: true
                }),
                graphSize: new SuperMap.REST.ThemeGraphSize({
                    maxGraphSize: 1,
                    minGraphSize: 0.35
                }),
                graphText: new SuperMap.REST.ThemeGraphText({
                    graphTextDisplayed: true,
                    graphTextFormat: SuperMap.REST.ThemeGraphTextFormat.VALUE,
                    graphTextStyle: new SuperMap.REST.ServerTextStyle({
                        sizeFixed: true,
                        fontHeight: 9,
                        fontWidth: 5
                    })
                }),
                graphType: SuperMap.REST.ThemeGraphType.BAR3D
            }),

                    //专题图参数对象
            themeParameters = new SuperMap.REST.ThemeParameters({
                themes: [themeGraph],
                dataSourceNames: ["China400"],
                datasetNames: ["County_R_1"]/*,
                joinItems: [joinItem]*/
            }),

                    //与服务端交互
            themeService = new SuperMap.REST.ThemeService(url, {
                eventListeners: {
                    "processCompleted": ThemeCompleted,
                    "processFailed": themeFailed
                }
            });
                    themeService.processAsync(themeParameters);
                }

    //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
    //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
    function ThemeCompleted(themeEventArgs) {
        if (themeEventArgs.result.resourceInfo.id) {
//            var Id = themeEventArgs.result.resourceInfo.id
//        alert(Id)
            themeLayer = new SuperMap.Layer.TiledDynamicRESTLayer("京津地区人口分布图_专题图",
url, { cacheEnabled: false, transparent: true,
    layersID: themeEventArgs.result.resourceInfo.id
}, { maxResolution: "auto" });
            themeLayer.events.on({ "layerInitialized": addThemelayer });

        }
    }
    function addThemelayer() {
        map.addLayer(themeLayer);
    }

    function themeFailed(serviceFailedEventArgs) {
        //doMapAlert("",serviceFailedEventArgs.error.errorMsg,true);
        alert(serviceFailedEventArgs.error.errorMsg);
    }

    //移除专题图图层
    function removeTheme() {
        if (map.layers.length > 1) {
            map.removeLayer(themeLayer, true);
        }
    }
</script>
</head>
<body onload="init()">
<div id="toolbar">
<input type="button" class="btn" value="创建专题图" onclick="addThemeGraph()" />
<input type="button" class="btn" value="移除专题图" onclick="removeTheme()" />
</div>
<div id="map"></div>
</body>
</html>

1个回答

排除代码问题后,建议在iDesktop里打开工作空间或数据源看下China400.1数据源下County_R_1数据集的坐标系和地图是否一致、有没有FLOWER_1995等字段,字段类型是否为数值型,比如 int、float、double。
建议先在iDesktop里按照上述js代码填的参数创建一个统计专题图,看下是否正常。

1,780EXP 2017年05月18日

我按照您所说的在idesktop建了一个统计专题图,正常显示。之后把代码中数据源改为了China400,运行程序还是同样没有结果。您看是我数据源和数据集名称对应错了吗?现在在idesktop查看各属性,麻烦帮我检查一下,以下是截图部分

另外我查看了地图属性和图层属性,两者坐标系名称不同,但是里面的对应项是一致的,不知会不会影响

可以私信我你的QQ,远程看下
请问,什么时间方便帮我远程一下,qq已发私信,谢谢!

已解决,统计专题图图表高宽是与地图单位一致,该图非经纬度,所以高宽要比经纬度时大很多,需要自己调一下参数。类参考有说明高宽设置需要与地图单位一致,即经纬度下高宽单位为度,投影坐标系为米。
http://support.supermap.com.cn:8090/iserver/iClient/forJavaScript/apidoc/files/SuperMap/REST/Theme/ThemeGraph-js.html

...