123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_themeLabel"></title>
- <script type="text/javascript" src="../js/include-web.js"></script>
- <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
- <div id="map" style="width: 100%;height:100%"></div>
- <script type="text/javascript">
- var map, themeLayer, options
- url = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-world/rest/maps/World";
- new ol.supermap.MapService(url).getMapInfo(function (serviceResult) {
- var mapJSONObj = serviceResult.result;
- map = new ol.Map({
- target: 'map',
- controls: ol.control.defaults({attributionOptions: {collapsed: false}})
- .extend([new ol.supermap.control.Logo()]),
- view: new ol.View({
- center: [0, 0],
- zoom: 2,
- projection: "EPSG:4326",
- multiWorld: true
- })
- });
- options = ol.source.TileSuperMapRest.optionsFromMapJSON(url, mapJSONObj);
- var layer = new ol.layer.Tile({
- source: new ol.source.TileSuperMapRest(options)
- });
- map.addLayer(layer);
- createTheme();
- });
- function createTheme() {
- var style1, style2, style3;
- style1 = new SuperMap.ServerTextStyle({
- fontHeight: 4,
- foreColor: new SuperMap.ServerColor(100, 20, 50),
- sizeFixed: true,
- bold: true
- });
- style2 = new SuperMap.ServerTextStyle({
- fontHeight: 4,
- foreColor: new SuperMap.ServerColor(250, 0, 0),
- sizeFixed: true,
- bold: true
- });
- style3 = new SuperMap.ServerTextStyle({
- fontHeight: 4,
- foreColor: new SuperMap.ServerColor(93, 95, 255),
- sizeFixed: true,
- bold: true
- });
- var themeLabelItem1, themeLabelItem2, themeLabelItem3, themeLabelItem4, themeLabelItem5, themeLabelItem6;
- themeLabelItem1 = new SuperMap.ThemeLabelItem({
- start: 0.0,
- end: 7800000,
- style: style1
- });
- themeLabelItem2 = new SuperMap.ThemeLabelItem({
- start: 7800000,
- end: 15000000,
- style: style2
- });
- themeLabelItem3 = new SuperMap.ThemeLabelItem({
- start: 15000000,
- end: 30000000,
- style: style3
- });
- themeLabelItem4 = new SuperMap.ThemeLabelItem({
- start: 0.0,
- end: 55,
- style: style1
- });
- themeLabelItem5 = new SuperMap.ThemeLabelItem({
- start: 55,
- end: 109,
- style: style2
- });
- themeLabelItem6 = new SuperMap.ThemeLabelItem({
- start: 109,
- end: 300,
- style: style3
- });
- var themeLabel = new SuperMap.ThemeLabel({
- matrixCells: [
- [new SuperMap.LabelThemeCell({
- themeLabel: new SuperMap.ThemeLabel({
- labelExpression: "CAPITAL",
- rangeExpression: "SmID",
- numericPrecision: 0,
- items: [themeLabelItem4, themeLabelItem5, themeLabelItem6]
- })
- })],
- [new SuperMap.LabelThemeCell({
- themeLabel: new SuperMap.ThemeLabel({
- labelExpression: "CAP_POP",
- rangeExpression: "CAP_POP",
- numericPrecision: 0,
- items: [themeLabelItem1, themeLabelItem2, themeLabelItem3]
- })
- })]
- ],
- background: new SuperMap.ThemeLabelBackground({
- backStyle: new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(179, 209, 193),
- fillOpaqueRate: 60,
- lineWidth: 0.1
- }),
- labelBackShape: "RECT"
- })
- });
- var themeParameters = new SuperMap.ThemeParameters({
- themes: [themeLabel],
- datasetNames: ["Capitals"],
- dataSourceNames: ["World"]
- });
- new ol.supermap.ThemeService(url).getThemeInfo(themeParameters, function (serviceResult) {
- var result = serviceResult.result;
- if (result && result.newResourceID) {
- themeLayer = new ol.layer.Tile({
- source: new ol.source.TileSuperMapRest({
- url: url,
- noWrap: true,
- cacheEnabled: false,
- transparent: true,
- layersID: result.newResourceID,
- transparent: true
- })
- });
- map.addLayer(themeLayer);
- }
- });
- }
- </script>
- </body>
- </html>
|