1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > 空间分析-核密度分析</ title >
6+
7+ < link rel ="stylesheet " href ="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css ">
8+ < link rel ="stylesheet " href ="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css ">
9+ </ head >
10+ < body style =" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0; ">
11+ < div id ="map " style ="margin:0 auto;width: 100%;height: 100% "> </ div >
12+
13+ < script type ="text/javascript " src ="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.js "> </ script >
14+ < script type ="text/javascript " src ="../../dist/iclient9-leaflet.js "> </ script >
15+ < script type ="text/javascript ">
16+ var map , densityAnalystService , densityAnalystParameters , densityAnalystResult ,
17+ themeService , themeGridRange , themeParameters , themeLayer ,
18+ baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-changchun/rest/maps/长春市区图" ,
19+ serviceUrl = "http://support.supermap.com.cn:8090/iserver/services/spatialanalyst-changchun/restjsr/spatialanalyst" ;
20+ map = L . map ( 'map' , {
21+ crs : L . CRS . NonEarthCRS ( {
22+ bounds : L . bounds ( [ 48.4 , - 7668.25 ] , [ 8958.85 , - 55.58 ] ) ,
23+ origin : L . point ( 48.4 , - 55.58 )
24+ } ) ,
25+ center : [ - 3861.911472192499 , 4503.6240321526 ] ,
26+ maxZoom : 18 ,
27+ zoom : 2
28+ } ) ;
29+ L . supermap . tiledMapLayer ( baseUrl , { noWrap : true } ) . addTo ( map ) ;
30+ densityAnalystProcess ( ) ;
31+
32+ function densityAnalystProcess ( ) {
33+ //创建点密度插值分析参数实例
34+ densityAnalystParameters = new SuperMap . DensityKernelAnalystParameters ( {
35+ //指定数据集
36+ dataset : "Railway@Changchun" ,
37+ //指定范围
38+ bounds : L . bounds ( [ 3800 , - 3800 ] , [ 8200 , - 2200 ] ) ,
39+ //指定数据集中用于核密度分析的字段
40+ fieldName : "SmLength" ,
41+ searchRadius : 50 , //Railway@Changchun 的单位是米
42+ // 结果数据集名称
43+ resultGridName : "KernelDensity_Result" ,
44+ deleteExistResultDataset : true
45+ } ) ;
46+ //创建一个核密度分析服务实例
47+ densityAnalystService = L . supermap . spatialAnalystService ( serviceUrl ) ;
48+ densityAnalystService . densityAnalysis ( densityAnalystParameters , function ( densityServiceResult ) {
49+ densityAnalystResult = densityServiceResult . result ;
50+ if ( densityAnalystResult && densityAnalystResult . dataset ) {
51+ //用栅格专题图展示分析结果
52+ showAnalysisResult_ThemeGridRange ( ) ;
53+ } else {
54+ alert ( densityServiceResult . error . errorMsg ) ;
55+ }
56+ } ) ;
57+ }
58+
59+ //构造栅格专题图
60+ function showAnalysisResult_ThemeGridRange ( ) {
61+ //创建专题图服务实例
62+ themeService = L . supermap . themeService ( baseUrl ) ;
63+ var color1 = new SuperMap . ServerColor ( 255 , 212 , 170 ) ,
64+ color2 = new SuperMap . ServerColor ( 255 , 127 , 0 ) ,
65+ color3 = new SuperMap . ServerColor ( 191 , 95 , 0 ) ,
66+ color4 = new SuperMap . ServerColor ( 255 , 0 , 0 ) ,
67+ color5 = new SuperMap . ServerColor ( 191 , 0 , 0 ) ;
68+ var themeGridRangeItem1 = new SuperMap . ThemeGridRangeItem ( {
69+ start : 0 ,
70+ end : 0.05 ,
71+ color : color1
72+ } ) ,
73+ themeGridRangeItem2 = new SuperMap . ThemeGridRangeItem ( {
74+ start : 0.05 ,
75+ end : 5 ,
76+ color : color2
77+ } ) ,
78+ themeGridRangeItem3 = new SuperMap . ThemeGridRangeItem ( {
79+ start : 5 ,
80+ end : 10 ,
81+ color : color3
82+ } ) ,
83+ themeGridRangeItem4 = new SuperMap . ThemeGridRangeItem ( {
84+ start : 10 ,
85+ end : 100 ,
86+ color : color4
87+ } ) ,
88+ themeGridRangeItem5 = new SuperMap . ThemeGridRangeItem ( {
89+ start : 100 ,
90+ end : 360 ,
91+ color : color5
92+ } ) ;
93+ themeGridRange = new SuperMap . ThemeGridRange ( {
94+ reverseColor : false ,
95+ rangeMode : SuperMap . RangeMode . EQUALINTERVAL ,
96+ //栅格分段专题图子项数组
97+ items : [ themeGridRangeItem1 ,
98+ themeGridRangeItem2 ,
99+ themeGridRangeItem3 ,
100+ themeGridRangeItem4 ,
101+ themeGridRangeItem5
102+ ]
103+ } ) ;
104+
105+ themeParameters = new SuperMap . ThemeParameters ( {
106+ //制作专题图的数据集
107+ datasetNames : [ densityAnalystResult . dataset . split ( '@' ) [ 0 ] ] ,
108+ dataSourceNames : [ "Changchun" ] ,
109+ joinItems : null ,
110+ themes : [ themeGridRange ]
111+ } ) ;
112+
113+ themeService . getThemeInfo ( themeParameters , function ( getThemeInfoServiceResult ) {
114+ var result = getThemeInfoServiceResult . result ;
115+ if ( result && result . newResourceID ) {
116+ themeLayer = L . supermap . tiledMapLayer ( baseUrl , {
117+ noWrap : true ,
118+ cacheEnabled : false ,
119+ transparent : true ,
120+ layersID : result . newResourceID ,
121+ opacity : 0.8
122+ } ) . addTo ( map ) ;
123+ }
124+ } ) . on ( 'failed' , function ( error ) {
125+ alert ( error . errorMsg ) ;
126+ } ) ;
127+ }
128+ </ script >
129+ </ body >
130+ </ html >
0 commit comments