<!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>

注:得到的结果图如下:

最新文章

  1. C#编程模式之扩展命令
  2. promise实例小球运动
  3. WPF 小技巧
  4. LaTeX插入图片方法 Inserting Images
  5. 技能获取与C语言学习情况
  6. 【GDI+】一些规则多边形分离的问题
  7. 鸟哥的linux私房菜学习记录之认识系统服务(daemons)
  8. svn使用(服务器端和客户端)
  9. Qt之坐标系统
  10. WCF入门(八)---WCF服务绑定
  11. 获取windows身份认证网站页面内容
  12. LOVEU
  13. 三篇IMO的文章
  14. SDOI2019R1游记
  15. sql-josn
  16. IDEA更换主题
  17. 第二十六节,滑动窗口和 Bounding Box 预测
  18. str、tuple、dict之间的相互转换
  19. java获取泛型类型
  20. js调起微信客户端

热门文章

  1. 前端MVC框架Backbone 1.1.0源码分析系列
  2. The Installation and Compilation of OpenCASCADE
  3. WPF MVVM框架下,VM界面写控件
  4. Python标准库13 循环器 (itertools)
  5. javascript之一切皆为对象2
  6. AspNetPager分页控件配置
  7. c# 我所理解的 值类型 and 引用类型
  8. js 利用throw 写的一个小程序
  9. unbuntu14.04 安装nginx配置
  10. ZOJ Problem Set - 1337 Pi 最大公约数