1010< body style =" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0; ">
1111< div id ="toolbar " class ="panel panel-primary " style =" position: absolute;top: 10px;right: 10px;text-align: center;z-index: 9999;border-radius: 4px; ">
1212 < div class ='panel-heading ' id ="panelheading ">
13- < h5 class ='panel-title text-center ' data-i18n ="resources.title_operatePlottingLayer "> </ h5 > </ div >
14- < div class ='panel-body content ' id ="panelbodycontent ">
13+ < h5 class ='panel-title text-center ' data-i18n ="resources.title_operatePlottingLayer "> </ h5 >
14+ </ div >
15+ < div class ='input-group ' style =" margin-bottom: 10px;top:10px;left:5px;right:5px;width: 340px; ">
1516 < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_createLayer " onclick ="createPlottingLayer() "/>
1617 < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_deleteLayer " onclick ="removePlottingLayer() "/>
1718 < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_drawMarker " onclick ="plotSymbol() "/>
1819 < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_cancelMarker " onclick ="plottingDrawCancel() "/>
1920 </ div >
21+ < div class ='input-group ' style =" margin-bottom: 12px;left:30px;width: 240px; ">
22+ < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_createChildLayer " onclick ="createChildPlotLayer() "/>
23+ < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_deleteChildLayer " onclick ="removeChildPlotLayer() "/>
24+ </ div >
25+ < div class ='input-group ' style =" margin-bottom: 10px;top:10px;left:5px;right:5px;width: 340px; ">
26+ < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_setPlottingLayerMinScale " onclick ="setPlottingLayerMinScale() "/>
27+ </ div >
28+ < div class ='input-group ' style =" margin-bottom: 10px;top:10px;left:5px;right:15px;width: 340px; ">
29+ < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_setPlottingLayerMaxScale " onclick ="setPlottingLayerMaxScale() "/>
30+ </ div >
31+ < div class ='input-group ' style =" margin-bottom: 10px;top:10px;left:5px;right:15px;width: 340px; ">
32+ < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_clearScale " onclick ="clearScale() "/>
33+ </ div >
34+ < div class ='input-group ' style =" margin-bottom: 10px;top:10px;left:5px;right:5px;width: 340px; ">
35+ < input type ="button " class ="btn btn-default " data-i18n ="[value]resources.btn_setSymScaleDefinition " onclick ="setSymScaleDefinition() "/>
36+ </ div >
37+ < div class ='input-group ' style =" margin-bottom: 10px;top:10px;left:5px;right:15px;width: 340px; ">
38+ < div class ='input-group ' style =" margin-bottom: 10px;left:10px;width: 300px; ">
39+ < span class ='input-group-addon ' data-i18n ="resources.btn_plotSize "> </ span >
40+ < select class ='form-control ' id ='plotSize '>
41+ < option value ='0 '> false</ option >
42+ < option value ='1 ' selected > true</ option >
43+ </ select >
44+ </ div >
45+ </ div >
46+ </ div >
47+ < div id ="map " style ="margin:0 auto;width: 100%;height: 100% ">
2048</ div >
21- < div id ="map " style ="margin:0 auto;width: 100%;height: 100% "> </ div >
22- < script type ="text/javascript " include ="bootstrap,widgets.alert,jquery " src ="../js/include-web.js "> </ script >
23- < script type ="text/javascript " include ="iclient-leaflet-css,iclient-plot-leaflet " src ="../../dist/leaflet/include-leaflet.js "> </ script >
49+ < script type ="text/javascript " include ="bootstrap,widgets.alert,plottingPanel " src ="../js/include-web.js "> </ script >
50+ < script type ="text/javascript " include ="leaflet,iclient-leaflet,iclient-leaflet-css,iclient-plot-leaflet " src ="../../dist/leaflet/include-leaflet.js "> </ script >
51+ < script type ="text/javascript " include ="PlotPanel,StylePanel,PlotMapPanel " src ="../js/plottingPanel/PlottingPanel.Include.js "> </ script >
52+ < script type ="text/javascript " src ="../../node_modules/pako/dist/pako_inflate.js "> </ script >
53+ < script type ="text/javascript " src ="../../node_modules/pako/dist/pako.min.js "> </ script >
2454< script type ="text/javascript ">
55+
2556 var host = window . isLocal ? window . server : "https://iserver.supermap.io" ;
2657 var url = host + "/iserver/services/map-china400/rest/maps/China_4326" ;
2758 var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/" ;
28- var map , plottingLayer , plottingLayers = [ ] , drawControl ;
59+ var map , plottingLayer , drawControl , childPlotLayer , visibleFlag ;
2960 map = L . map ( 'map' , {
3061 preferCanvas : true ,
3162 crs : L . CRS . EPSG4326 ,
3263 center : [ 35 , 104 ] ,
3364 maxZoom : 18 ,
3465 zoom : 3
3566 } ) ;
36- new L . supermap . TiledMapLayer ( url ) . addTo ( map ) ;
67+
68+ L . supermap . tiledMapLayer ( url ) . addTo ( map ) ;
3769 drawControl = L . supermap . plotting . drawControl ( ) ;
3870 drawControl . addTo ( map ) ;
3971 var editControl = L . supermap . plotting . editControl ( ) ;
4072 editControl . addTo ( map ) ;
73+ var plotting = L . supermap . plotting . getControl ( map , serverUrl ) ;
74+ var plotMapManager = plotting . getPlotMapManager ( ) ;
75+
4176 function createPlottingLayer ( ) {
4277 widgets . alert . clearAlert ( ) ;
43- var plottingLayerName = "plottingLayer_" + Math . ceil ( Math . random ( ) * 1000 ) ;
78+
79+ var plottingLayerName = "图元层" ;
4480 plottingLayer = L . supermap . plotting . plottingLayer ( plottingLayerName , serverUrl ) ;
45- drawControl . setDrawingLayer ( plottingLayer ) ;
4681 plottingLayer . addTo ( map ) ;
47- plottingLayers . push ( plottingLayer ) ;
82+ plotMapManager . setActivePlottingLayer ( plottingLayer ) ;
4883 var successMessage = "图层 " + plottingLayer . name + " 创建成功" ;
4984 widgets . alert . showAlert ( successMessage , true ) ;
5085 }
86+
5187 function removePlottingLayer ( ) {
5288 widgets . alert . clearAlert ( ) ;
53- if ( plottingLayers . length !== 0 ) {
54- var tempPlottingLayer = plottingLayers [ plottingLayers . length - 1 ] ;
89+ if ( plotMapManager . getPlottingLayers ( ) . length !== 0 ) {
90+ var tempPlottingLayer = plotMapManager . getActivePlottingLayer ( ) ;
5591 map . removeLayer ( tempPlottingLayer ) ;
5692 var successMessage = "图层 " + tempPlottingLayer . name + " 删除成功" ;
57- plottingLayers . splice ( plottingLayers . length - 1 , 1 ) ;
58- if ( plottingLayers . length > 0 ) {
59- drawControl . setDrawingLayer ( plottingLayers [ plottingLayers . length - 1 ] ) ;
93+ if ( plotMapManager . getPlottingLayers ( ) . length > 0 ) {
94+ plotMapManager . setActivePlottingLayer ( plotMapManager . getPlottingLayers ( ) [ plotMapManager . getPlottingLayers ( ) . length - 1 ] ) ;
6095 }
6196 widgets . alert . showAlert ( successMessage , true ) ;
6297 } else {
6398 widgets . alert . showAlert ( "当前地图无标绘图层" , false ) ;
6499 }
65100 }
101+
102+ function createChildPlotLayer ( ) {
103+ widgets . alert . clearAlert ( ) ;
104+ if ( plotMapManager . getActivePlottingLayer ( ) !== undefined ) {
105+ var plottingLayerName = "子图层" ;
106+ var plottingLayerCaption = plottingLayerName ;
107+ childPlotLayer = L . supermap . plotting . childPlotLayer ( plottingLayerName , plottingLayerCaption ) ;
108+ plottingLayer . addChildPlotLayer ( childPlotLayer ) ;
109+ plottingLayer . setActiveChildPlotLayer ( childPlotLayer ) ;
110+ } else {
111+ widgets . alert . showAlert ( "请先添加标绘图层!" , true ) ;
112+ }
113+ var successMessage = "子图层 " + childPlotLayer . name + " 创建成功" ;
114+ widgets . alert . showAlert ( successMessage , true ) ;
115+ }
116+
117+ function removeChildPlotLayer ( ) {
118+ widgets . alert . clearAlert ( ) ;
119+ var childPlotLayer = plotMapManager . getActiveChildPlotLayer ( ) ;
120+ if ( childPlotLayer != null && childPlotLayer . getParent ( ) != null ) {
121+ childPlotLayer . getParent ( ) . removeChildPlotLayer ( childPlotLayer ) ;
122+ if ( childPlotLayer . getParent ( ) . getChildPlotLayers ( ) . length > 0 ) {
123+ plotMapManager . setActiveChildPlotLayer ( childPlotLayer . getParent ( ) . getChildPlotLayers ( ) [ childPlotLayer . getParent ( ) . getChildPlotLayers ( ) . length - 1 ] ) ;
124+ }
125+
126+ var successMessage = "子图层 " + childPlotLayer . name + " 删除成功" ;
127+ widgets . alert . showAlert ( successMessage , true ) ;
128+ } else {
129+ widgets . alert . showAlert ( "当前地图无标绘图层或子图层" , false ) ;
130+ }
131+ }
132+
133+ function setPlottingLayerMinScale ( ) {
134+ plotMapManager . getActivePlottingLayer ( ) . setMinVisibleScale ( map . _layers [ 27 ] . getScale ( ) ) ;
135+ }
136+
137+ function setPlottingLayerMaxScale ( ) {
138+ plotMapManager . getActivePlottingLayer ( ) . setMaxVisibleScale ( map . _layers [ 27 ] . getScale ( ) ) ;
139+ }
140+
141+ function clearScale ( ) {
142+ plotMapManager . getActivePlottingLayer ( ) . clearVisibleScale ( ) ;
143+ }
144+
145+ function setSymScaleDefinition ( ) {
146+ if ( document . getElementById ( "plotSize" ) . selectedIndex === 0 ) {
147+ plotMapManager . getActivePlottingLayer ( ) . setSymScaleDefinition ( map . _layers [ 27 ] . getScale ( ) , false ) ;
148+ } else {
149+ plotMapManager . getActivePlottingLayer ( ) . setSymScaleDefinition ( map . _layers [ 27 ] . getScale ( ) , true ) ;
150+ }
151+ }
152+
66153 function plotSymbol ( ) {
67154 widgets . alert . clearAlert ( ) ;
68155 if ( drawControl . drawingLayer !== undefined ) {
@@ -74,15 +161,18 @@ <h5 class='panel-title text-center' data-i18n="resources.title_operatePlottingLa
74161 widgets . alert . showAlert ( "请先添加标绘图层!" , true ) ;
75162 }
76163 }
164+
77165 function plottingDrawCancel ( ) {
78166 widgets . alert . clearAlert ( ) ;
79167 drawControl . handler . disable ( ) ;
80168 }
169+
81170 $ ( document ) . ready ( function ( ) {
82171 $ ( '#panelheading' ) . click ( function ( ) {
83172 $ ( '#panelbodycontent' ) . toggle ( ) ;
173+ $ ( '#popupWin' ) . toggle ( ) ;
84174 } ) ;
85175 } ) ;
86176</ script >
87177</ body >
88- </ html >
178+ </ html >
0 commit comments