33*********************************************************************-->
44<!DOCTYPE html>
55< html >
6- < head >
7- < meta charset ="UTF-8 ">
6+ < head >
7+ < meta charset ="UTF-8 " / >
88 < title data-i18n ="resources.text_mapOverlay "> </ title >
99 < script type ="text/javascript " src ="../js/include-web.js "> </ script >
1010 < script type ="text/javascript " src ="../../dist/ol/include-ol.js "> </ script >
11- </ head >
12- < body style =" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0; ">
13- < div id ="map " style ="width: 100%;height:100% "> </ div >
14- < script type ="text/javascript ">
15- var map , urlWorld = ( window . isLocal ? window . server : "https://iserver.supermap.io" ) + "/iserver/services/map-world/rest/maps/World" ,
16- urlJinjing = ( window . isLocal ? window . server : "https://iserver.supermap.io" ) + "/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图" ;
17- map = new ol . Map ( {
18- target : 'map' ,
19- controls : ol . control . defaults ( { attributionOptions : { collapsed : false } } )
20- . extend ( [ new ol . supermap . control . Logo ( ) ] ) ,
21- view : new ol . View ( {
11+ </ head >
12+ < body style ="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0 ">
13+ < div id ="map " style ="width: 100%; height: 100% "> </ div >
14+ < script type ="text/javascript ">
15+ var map ,
16+ urlWorld =
17+ ( window . isLocal ? window . server : 'https://iserver.supermap.io' ) +
18+ '/iserver/services/map-world/rest/maps/World' ,
19+ urlJinjing =
20+ ( window . isLocal ? window . server : 'https://iserver.supermap.io' ) +
21+ '/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图' ;
22+ // 方式一:1.调用 ol.supermap.initMap,根据 SuperMap iServer 地图服务的地图信息,创建地图和底图
23+ // 2.调用 ol.source.TileSuperMapRest 创建叠加图层
24+ ol . supermap
25+ . initMap ( urlWorld , {
26+ mapOptions : {
27+ controls : ol . control
28+ . defaults ( { attributionOptions : { collapsed : false } } )
29+ . extend ( [ new ol . supermap . control . Logo ( ) ] )
30+ } ,
31+ viewOptions : {
2232 center : [ 116.85 , 39.79 ] ,
23- zoom : 7 ,
24- projection : 'EPSG:4326' ,
25- multiWorld : true
33+ zoom : 8
34+ }
2635 } )
27- } ) ;
28- var worldLayer = new ol . layer . Tile ( {
29- source : new ol . source . TileSuperMapRest ( {
36+ . then ( ( { map, source } ) => {
37+ var Jinjing = new ol . layer . Tile ( {
38+ source : new ol . source . TileSuperMapRest ( {
39+ url : urlJinjing ,
40+ tileGrid : source . getTileGrid ( )
41+ } )
42+ } ) ;
43+ map . addLayer ( Jinjing ) ;
44+ } ) ;
45+ /* 方式二:1.调用 ol.supermap.MapService,获取 SuperMap iServer 地图服务的地图信息
46+ 2.调用 ol.supermap.viewOptionsFromMapJSON 获取地图视图参数
47+ 3.调用 ol.Map 创建地图
48+ 4.调用 ol.layer.Tile 与 ol.source.TileSuperMapRest 创建底图和叠加图层
49+ new ol.supermap.MapService(urlJinjing).getMapInfo(function (serviceResult) {
50+ const mapObj = serviceResult.result;
51+ map = new ol.Map({
52+ target: 'map',
53+ controls: ol.control
54+ .defaults({ attributionOptions: { collapsed: false } })
55+ .extend([new ol.supermap.control.Logo()]),
56+ view: new ol.View(ol.supermap.viewOptionsFromMapJSON(mapObj))
57+ });
58+ var worldLayer = new ol.layer.Tile({
59+ source: new ol.source.TileSuperMapRest({
3060 url: urlWorld
31- } ) ,
32- projection : 'EPSG:4326'
33- } ) ;
34- map . addLayer ( worldLayer ) ;
35- var jinJingLayer = new ol . layer . Tile ( {
36- source : new ol . source . TileSuperMapRest ( {
37- url : urlJinjing ,
38- origin : [ - 180 , 90 ] ,
39- transparent : true
40- } ) ,
41- projection : 'EPSG:4326'
42- } ) ;
43- map . addLayer ( jinJingLayer ) ;
44-
45- </ script >
46- </ body >
47- </ html >
61+ }),
62+ projection: 'EPSG:4326'
63+ });
64+ map.addLayer(worldLayer);
65+ var jinJingLayer = new ol.layer.Tile({
66+ source: new ol.source.TileSuperMapRest(ol.source.TileSuperMapRest.optionsFromMapJSON(urlJinjing, mapObj))
67+ });
68+ map.addLayer(jinJingLayer);
69+ });
70+ */
71+ </ script >
72+ </ body >
73+ </ html >
0 commit comments