123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_themeUnique"></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-china400/rest/maps/China";
- 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: [12406035, 4304933],
- zoom: 4,
- projection: "EPSG:3857",
- 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, style4, style5, style6;
- style1 = new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(248, 203, 249),
- lineColor: new SuperMap.ServerColor(255, 255, 255),
- lineWidth: 0.1
- });
- style2 = new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(196, 255, 189),
- lineColor: new SuperMap.ServerColor(255, 255, 255),
- lineWidth: 0.1
- });
- style3 = new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(255, 173, 173),
- lineColor: new SuperMap.ServerColor(255, 255, 255),
- lineWidth: 0.1
- });
- style4 = new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(255, 239, 168),
- lineColor: new SuperMap.ServerColor(255, 255, 255),
- lineWidth: 0.1
- });
- style5 = new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(173, 209, 255),
- lineColor: new SuperMap.ServerColor(255, 255, 255),
- lineWidth: 0.1
- });
- style6 = new SuperMap.ServerStyle({
- fillForeColor: new SuperMap.ServerColor(132, 164, 232),
- lineColor: new SuperMap.ServerColor(255, 255, 255),
- lineWidth: 0.1
- });
- var themeUniqueIteme1 = new SuperMap.ThemeUniqueItem({
- unique: "黑龙江省",
- style: style1
- }),
- themeUniqueIteme2 = new SuperMap.ThemeUniqueItem({
- unique: "湖北省",
- style: style2
- }),
- themeUniqueIteme3 = new SuperMap.ThemeUniqueItem({
- unique: "吉林省",
- style: style3
- }),
- themeUniqueIteme4 = new SuperMap.ThemeUniqueItem({
- unique: "内蒙古自治区",
- style: style4
- }),
- themeUniqueIteme5 = new SuperMap.ThemeUniqueItem({
- unique: "青海省",
- style: style5
- }),
- themeUniqueIteme6 = new SuperMap.ThemeUniqueItem({
- unique: "新疆维吾尔自治区",
- style: style6
- }),
- themeUniqueIteme7 = new SuperMap.ThemeUniqueItem({
- unique: "云南省",
- style: style1
- }),
- themeUniqueIteme8 = new SuperMap.ThemeUniqueItem({
- unique: "四川省",
- style: style4
- }),
- themeUniqueIteme9 = new SuperMap.ThemeUniqueItem({
- unique: "贵州省",
- style: style3
- }),
- themeUniqueIteme10 = new SuperMap.ThemeUniqueItem({
- unique: "甘肃省",
- style: style3
- }),
- themeUniqueIteme11 = new SuperMap.ThemeUniqueItem({
- unique: "宁夏回族自治区",
- style: style5
- }),
- themeUniqueIteme12 = new SuperMap.ThemeUniqueItem({
- unique: "重庆市",
- style: style6
- }),
- themeUniqueIteme13 = new SuperMap.ThemeUniqueItem({
- unique: "山东省",
- style: style1
- }),
- themeUniqueIteme14 = new SuperMap.ThemeUniqueItem({
- unique: "安徽省",
- style: style2
- }),
- themeUniqueIteme15 = new SuperMap.ThemeUniqueItem({
- unique: "江西省",
- style: style3
- }),
- themeUniqueIteme16 = new SuperMap.ThemeUniqueItem({
- unique: "浙江省",
- style: style4
- }),
- themeUniqueIteme17 = new SuperMap.ThemeUniqueItem({
- unique: "台湾省",
- style: style2
- }),
- themeUniqueIteme18 = new SuperMap.ThemeUniqueItem({
- unique: "江苏省",
- style: style6
- }),
- themeUniqueIteme19 = new SuperMap.ThemeUniqueItem({
- unique: "湖南省",
- style: style5
- }),
- themeUniqueIteme20 = new SuperMap.ThemeUniqueItem({
- unique: "河南省",
- style: style4
- }),
- themeUniqueIteme21 = new SuperMap.ThemeUniqueItem({
- unique: "河北省",
- style: style3
- }),
- themeUniqueIteme22 = new SuperMap.ThemeUniqueItem({
- unique: "福建省",
- style: style5
- }),
- themeUniqueIteme23 = new SuperMap.ThemeUniqueItem({
- unique: "广西壮族自治区",
- style: style6
- }),
- themeUniqueIteme24 = new SuperMap.ThemeUniqueItem({
- unique: "西藏自治区",
- style: style2
- }),
- themeUniqueIteme25 = new SuperMap.ThemeUniqueItem({
- unique: "广东省",
- style: style4
- }),
- themeUniqueIteme26 = new SuperMap.ThemeUniqueItem({
- unique: "山西省",
- style: style2
- }),
- themeUniqueIteme27 = new SuperMap.ThemeUniqueItem({
- unique: "陕西省",
- style: style1
- }),
- themeUniqueIteme28 = new SuperMap.ThemeUniqueItem({
- unique: "天津市",
- style: style5
- }),
- themeUniqueIteme29 = new SuperMap.ThemeUniqueItem({
- unique: "北京市",
- style: style2
- }),
- themeUniqueIteme30 = new SuperMap.ThemeUniqueItem({
- unique: "辽宁省",
- style: style1
- });
- var themeUniqueItemes = [
- themeUniqueIteme1, themeUniqueIteme2, themeUniqueIteme3, themeUniqueIteme4, themeUniqueIteme5,
- themeUniqueIteme6, themeUniqueIteme7, themeUniqueIteme8, themeUniqueIteme9, themeUniqueIteme10,
- themeUniqueIteme11, themeUniqueIteme12, themeUniqueIteme13, themeUniqueIteme14, themeUniqueIteme15,
- themeUniqueIteme16, themeUniqueIteme17, themeUniqueIteme18, themeUniqueIteme19, themeUniqueIteme20,
- themeUniqueIteme21, themeUniqueIteme22, themeUniqueIteme23, themeUniqueIteme24, themeUniqueIteme25,
- themeUniqueIteme26, themeUniqueIteme27, themeUniqueIteme28, themeUniqueIteme29, themeUniqueIteme30
- ];
- var themeUnique = new SuperMap.ThemeUnique({
- uniqueExpression: "Name",
- items: themeUniqueItemes,
- defaultStyle: style1
- });
- var themeParameters = new SuperMap.ThemeParameters({
- datasetNames: ["China_Province_pg"],
- dataSourceNames: ["China"],
- themes: [themeUnique]
- });
- 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>
|