123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title data-i18n="resources.title_themeLabel"></title>
- <style type="text/css">
- .editPane {
- position: absolute;
- right: 60px;
- top: 50px;
- text-align: center;
- background: #FFF;
- z-index: 1000;
- }
- </style>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
- <div class='panel panel-primary editPane' id='editPane' style="z-index: 99999">
- <div class='panel-heading'>
- <h5 class='panel-title text-center' data-i18n="resources.title_themeLabel"></h5>
- </div>
- <div class='panel-body' id='params'>
- <p></p>
- <div align='right' class='button-group'>
- <input type='button' id='btn1' class='btn btn-primary' data-i18n="[value]resources.btn_addThemeLayer" onclick="addThemeLabel()"/>
- <input type='button' id='btn2' class='btn btn-primary' data-i18n="[value]resources.text_input_value_clear" onclick="removeTheme()"/>
- </div>
- </div>
- </div>
- <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
- <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
- <script type="text/javascript">
- var map, local, baseLayer, layersID, themeLayer,
- host = window.isLocal ? window.server : "https://iserver.supermap.io",
- url = host + "/iserver/services/map-world/rest/maps/World";
- 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: true
- }, {maxResolution: "auto"});
- baseLayer.events.on({"layerInitialized": addLayer});
- function addLayer() {
- map.addLayer(baseLayer);
- map.setCenter(new SuperMap.LonLat(0, 0), 0);
- map.allOverlays = true;
- }
- function addThemeLabel() {
- removeTheme();
- var themeService = new SuperMap.REST.ThemeService(url, {
- eventListeners: {
- "processCompleted": themeCompleted,
- "processFailed": themeFailed
- }
- }),
- style1 = new SuperMap.REST.ServerTextStyle({
- fontHeight: 4,
- foreColor: new SuperMap.REST.ServerColor(100, 20, 50),
- sizeFixed: true,
- bold: true
- }),
- style2 = new SuperMap.REST.ServerTextStyle({
- fontHeight: 4,
- foreColor: new SuperMap.REST.ServerColor(250, 0, 0),
- sizeFixed: true,
- bold: true
- }),
- style3 = new SuperMap.REST.ServerTextStyle({
- fontHeight: 4,
- foreColor: new SuperMap.REST.ServerColor(93, 95, 255),
- sizeFixed: true,
- bold: true
- }),
- themeLabelIteme1 = new SuperMap.REST.ThemeLabelItem({
- start: 0.0,
- end: 7800000,
- style: style1
- }),
- themeLabelIteme2 = new SuperMap.REST.ThemeLabelItem({
- start: 7800000,
- end: 15000000,
- style: style2
- }),
- themeLabelIteme3 = new SuperMap.REST.ThemeLabelItem({
- start: 15000000,
- end: 30000000,
- style: style3
- }),
- themeLabelIteme4 = new SuperMap.REST.ThemeLabelItem({
- start: 0.0,
- end: 55,
- style: style1
- }),
- themeLabelIteme5 = new SuperMap.REST.ThemeLabelItem({
- start: 55,
- end: 109,
- style: style2
- }),
- themeLabelIteme6 = new SuperMap.REST.ThemeLabelItem({
- start: 109,
- end: 300,
- style: style3
- }),
- themeLabelOne = new SuperMap.REST.ThemeLabel({
- labelExpression: "CAPITAL",
- rangeExpression: "SmID",
- numericPrecision: 0,
- items: [themeLabelIteme4, themeLabelIteme5, themeLabelIteme6]
- }),
- themeLabelTwo = new SuperMap.REST.ThemeLabel({
- labelExpression: "CAP_POP",
- rangeExpression: "CAP_POP",
- numericPrecision: 0,
- items: [themeLabelIteme1, themeLabelIteme2, themeLabelIteme3]
- }),
- //创建矩阵标签元素
- LabelThemeCellOne = new SuperMap.REST.LabelThemeCell({
- themeLabel: themeLabelOne
- }),
- LabelThemeCellTwo = new SuperMap.REST.LabelThemeCell({
- themeLabel: themeLabelTwo
- }),
- backStyle = new SuperMap.REST.ServerStyle({
- fillForeColor: new SuperMap.REST.ServerColor(255, 255, 0),
- fillOpaqueRate: 60,
- lineWidth: 0.1
- }),
- //创建矩阵标签专题图
- themeLabel = new SuperMap.REST.ThemeLabel({
- matrixCells: [[LabelThemeCellOne], [LabelThemeCellTwo]],
- background: new SuperMap.REST.ThemeLabelBackground({
- backStyle: backStyle,
- labelBackShape: "RECT"
- })
- }),
- themeParameters = new SuperMap.REST.ThemeParameters({
- themes: [themeLabel],
- datasetNames: ["Capitals"],
- dataSourceNames: ["World"],
- types: ['POINT']
- });
- themeService.processAsync(themeParameters);
- }
- function themeCompleted(themeEventArgs) {
- if (themeEventArgs.result.resourceInfo.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);
- widgets.alert.showAlert(serviceFailedEventArgs.error.errorMsg,false);
- }
- function removeTheme() {
- if (map.layers.length > 1) {
- map.removeLayer(themeLayer, true);
- }
- }
- </script>
- </body>
- </html>
|