• supermap iclient for js 标签专题图(服务端)


    <!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-yh/rest/maps/world";
    //url="http://192.168.15.133:8090/iserver/services/map-yh/rest/maps/world";
    function init(){
    map = new SuperMap.Map("map",{controls: [
    new SuperMap.Control.LayerSwitcher(),
    new SuperMap.Control.ScaleLine(),
    new SuperMap.Control.Zoom(),
    new SuperMap.Control.Navigation({
    dragPanOptions: {
    enableKinetic: true
    }
    })]
    });
    baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("world", url, {transparent: true, cacheEnabled: false}, {maxResolution:"auto"});
    baseLayer.events.on({"layerInitialized":addLayer});
    }
    function addLayer() {
    map.addLayer(baseLayer);
    map.setCenter(new SuperMap.LonLat(0.0,-3.19), 0);
    map.allOverlays = true;
    }

    //添加标签专题图
    function addThemeLabel() {
    removeTheme();
    var themeService = new SuperMap.REST.ThemeService(url, {eventListeners:{"processCompleted": themeCompleted, "processFailed": themeFailed}}),

    //创建矩阵标签专题图
    themeLabel = new SuperMap.REST.ThemeLabel({
    labelExpression: "CAPITAL_CH",
    numericPrecision: 2,
    overlapAvoided: true
    }),
    themeParameters = new SuperMap.REST.ThemeParameters({
    themes: [themeLabel],
    datasetNames: ["Capital"],
    dataSourceNames: ["ORCL"]

    });
    themeService.processAsync(themeParameters);
    }
    function themeCompleted(themeEventArgs) {
    if(themeEventArgs.result.resourceInfo.id) {
    themeLayer = new SuperMap.Layer.TiledDynamicRESTLayer("各国首都标签专题图", url, {cacheEnabled:false,transparent: true,overlapDisplayed: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="addThemeLabel()" />
    <input type="button" class="btn" value="移除专题图" onclick="removeTheme()" />
    </div>
    <div id="map"></div>
    </body>
    </html>

    注:得到的结果图如下:

  • 相关阅读:
    span 固定宽度且与其它元素同一行的样式设置
    height、clientHeight、scrollHeight、offsetHeight区别
    jquery选择器多值情况处理(取select列表选项的值)
    用Javascript取float型小数点后两位,例22.127456取成22.13,如何做?
    【JS获取与设置】FCKeditor编辑器的值
    浅析java位运算符计算方式
    分治策略(算法)
    Java GUI入门教程
    Java面向对象知识总结
    数据结构(Java)——图的基础算法
  • 原文地址:https://www.cnblogs.com/yaohuimo/p/5942371.html
Copyright © 2020-2023  润新知