9
9
< script type ="text/javascript " include ="turf,leaflet.draw " src ="../../dist/include-leaflet.js "> </ script >
10
10
< script type ="text/javascript " include ="bootstrap,bootstrap-select,widgets.alert " src ="../js/include-web.js "> </ script >
11
11
< script type ="text/javascript ">
12
- var unit ;
13
12
var host = window . isLocal ? document . location . protocol + "//" + document . location . host : "http://support.supermap.com.cn:8090" ,
14
13
url = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图" ,
15
14
turfLayer , resultLayer , urlWorld ,
34
33
35
34
bindEvents ( ) ;
36
35
36
+ $ ( '#menuSelect' ) . change ( ) ;
37
+
37
38
function initEditView ( ) {
38
39
var infoView = L . control ( { position : 'topright' } ) ;
39
40
infoView . onAdd = function ( ) {
44
45
<div class='panel-heading'>
45
46
<h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
46
47
</div>
47
- <div class='panel panel-body chooseItems'>
48
+ <div class='panel panel-body chooseItems' style="margin-bottom:0px;padding-bottom: 0px" >
48
49
<select class='form-control' id='menuSelect' >
49
- <option value= null selected='selected'>请选择方法</option>
50
- <option value='along'>along</option>
50
+ <option value='along' selected='selected'>along</option>
51
51
<option value='area'>area</option>
52
52
<option value='bbox'>bbox</option>
53
53
<option value='center'>center</option>
@@ -60,26 +60,26 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
60
60
<option value='buffer'>buffer</option>
61
61
<option value='circle'>circle</option>
62
62
</select>
63
- </div>
64
- <div class='panel-body' id='params'>
63
+ </div>
64
+ <hr/>
65
+ <div class='panel-body' id='params' style="padding-top: 0px">
65
66
<div class='input-group'>
66
- <span class='input-group-addon'>请选择距离的单位 </span>
67
+ <span class='input-group-addon'>距离单位 </span>
67
68
<select class='form-control' id='unitSelect' name='unitSelect'>
68
- <option value= null >请选择</option>
69
- <option value='kilometers'>kilometers</option>
69
+ <option value='kilometers' selected = "selected">kilometers</option>
70
70
<option value='miles'>miles</option>
71
71
<option value='degrees'>degrees</option>
72
72
<option value='radians'>radians</option>
73
73
</select>
74
74
</div>
75
75
<p></p>
76
76
<div class='input-group'>
77
- <span class='input-group-addon'>请输入距起点距离 </span>
78
- <input id='distance' type='text' class='form-control' placeholder="距离" />
77
+ <span class='input-group-addon'>距起点距离 </span>
78
+ <input id='distance' type='text' class='form-control' placeholder="距离" val="0.5" />
79
79
</div>
80
80
<p></p>
81
81
<div class='input-group'>
82
- <span class='input-group-addon'>请输入方位 </span>
82
+ <span class='input-group-addon'>方位 </span>
83
83
<input id='bearing' type='text' class='form-control' placeholder="-180度到180度之间"/>
84
84
</div>
85
85
<p></p>
@@ -99,10 +99,10 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
99
99
100
100
//初始化事件
101
101
function bindEvents ( ) {
102
- //获取单位
103
- $ ( '#unitSelect' ) . change ( function ( ) {
104
- unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
105
- } ) ;
102
+ // //获取单位
103
+ // $('#unitSelect').change(function () {
104
+ // unit = $('#unitSelect').children('option:selected').val();
105
+ // });
106
106
//控件栏取消地图事件
107
107
$ ( "#editPane" ) . mouseover ( function ( e ) {
108
108
map . dragging . disable ( ) ;
@@ -123,12 +123,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
123
123
url = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图" ;
124
124
baseLayer = L . supermap . tiledMapLayer ( url , { prjCoordSys : { "epsgCode" : 4326 } } ) . addTo ( map ) ;
125
125
//第一个隐藏右侧菜单
126
- if ( $ ( "#menuSelect" ) . get ( 0 ) . selectedIndex === 0 ) {
127
- setDefaultCenter ( 39.91 , 116.383572 , 11 ) ;
128
- hidePanel ( ) ;
129
- clearControl ( ) ;
130
126
131
- } else {
132
127
choose = $ ( '#menuSelect' ) . children ( 'option:selected' ) . val ( ) ;
133
128
reset ( ) ;
134
129
@@ -143,11 +138,12 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
143
138
$ ( '.input-group:eq(1)' ) . show ( ) ;
144
139
$ ( '.input-group:eq(2)' ) . hide ( ) ;
145
140
$ ( '.input-group:eq(3)' ) . show ( ) ;
146
- $ ( '.input-group:eq(1)>span' ) . text ( '请输入距起点距离 ' ) ;
147
- $ ( '.input-group:eq(1)>input' ) . attr ( 'placeholder' , '全长1.175千米约合0.73英里' ) ;
141
+ $ ( '.input-group:eq(1)>span' ) . text ( '距起点距离 ' ) ;
142
+ $ ( '.input-group:eq(1)>input' ) . val ( "0.5" ) ;
148
143
149
144
$ ( '.input-group:eq(1)>input' ) . focusout ( function ( ) {
150
145
val = $ ( '.input-group:eq(1)>input' ) . val ( ) ;
146
+ var unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
151
147
if ( ( unit === 'kilometers' && val > 1.1753172567467551 ) || ( unit === 'miles' && val > 0.7303085417726581 ) || ( unit === 'degrees' && val > 0.010566564943528475 ) || ( unit === 'radians' && val > 0.00018442134893248942 ) ) {
152
148
widgets . alert . showAlert ( '超出全程距离范围,请重新填写' , false , 260 ) ;
153
149
$ ( '.input-group:eq(1)>input' ) . val ( '' ) ;
@@ -160,7 +156,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
160
156
$ ( '#calc' ) . val ( '点击生成对应的点' ) ;
161
157
}
162
158
else if ( choose === 'area' ) {
163
- widgets . alert . showAlert ( '选择左侧控件,按下鼠标左键,画出自定义图层,再点右侧按钮进行面积计算 ' , true , 260 ) ;
159
+ widgets . alert . showAlert ( '使用左侧绘图控件绘制面,点击右侧按钮进行计算 ' , true , 500 ) ;
164
160
$ ( '.panel-heading>h5' ) . text ( '面积测量' ) ;
165
161
clearControl ( ) ;
166
162
setDefaultCenter ( 39.90455699411283 , 116.407283 , 11 ) ;
@@ -191,9 +187,9 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
191
187
$ ( '.input-group:eq(1)' ) . show ( ) ;
192
188
$ ( '.input-group:eq(2)' ) . show ( ) ;
193
189
$ ( '.input-group:eq(3)' ) . show ( ) ;
194
- $ ( '.input-group:eq(1)>span' ) . text ( '请输入距起点距离 ' ) ;
195
- $ ( '.input-group:eq(1)>input' ) . unbind ( 'focusout' ) . attr ( 'placeholder' , '请输入距起点距离' ) ;
196
- $ ( '.input-group:eq(2)>span' ) . text ( '请输入方位 ' ) ;
190
+ $ ( '.input-group:eq(1)>span' ) . text ( '距起点距离 ' ) ;
191
+ $ ( '.input-group:eq(1)>input' ) . unbind ( 'focusout' ) . val ( "0.5" ) ;
192
+ $ ( '.input-group:eq(2)>span' ) . text ( '方位 ' ) ;
197
193
$ ( '.input-group:eq(2)>input' ) . attr ( 'placeholder' , '请输入[-180,180]范围内的值' ) ;
198
194
setDestinationIcon ( ) ;
199
195
clearControl ( ) ;
@@ -234,7 +230,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
234
230
$ ( '#calc' ) . val ( '计算大圆航线' ) ;
235
231
}
236
232
else if ( choose === 'square' ) {
237
- widgets . alert . showAlert ( '选择左侧控件,按下鼠标左键,画出自定义矩形,再点右侧按钮计算最小外切正方形 ' , true , 260 ) ;
233
+ widgets . alert . showAlert ( '使用左侧绘制控件绘制矩形,点击右侧按钮计算最小外切正方形 ' , true , 500 ) ;
238
234
$ ( '.panel-heading>h5' ) . text ( '最小外切正方形' ) ;
239
235
setDefaultCenter ( 39.70914100034369 , 116.11697300062501 , 14 ) ;
240
236
clearControl ( ) ;
@@ -272,7 +268,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
272
268
}
273
269
else if ( choose === 'buffer' ) {
274
270
$ ( '.panel-heading>h5' ) . text ( 'buffer缓冲区' ) ;
275
- widgets . alert . showAlert ( '请先点击左侧控件标记一个点 ' , true ) ;
271
+ widgets . alert . showAlert ( '使用左侧控件标记一个点 ' , true ) ;
276
272
clearControl ( ) ;
277
273
setDefaultCenter ( 40 , 116.83 , 9 ) ;
278
274
drawController ( false , false , false , false , false , false , true ) ;
@@ -282,10 +278,10 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
282
278
$ ( '.input-group:eq(1)' ) . show ( ) ; //步长
283
279
$ ( '.input-group:eq(2)' ) . show ( ) ; //半径
284
280
$ ( '.input-group:eq(3)' ) . show ( ) ;
285
- $ ( '.input-group:eq(1)>span' ) . text ( '请输入步长 ' ) ; //步长
286
- $ ( '.input-group:eq(1)>input' ) . unbind ( 'focusout' ) . attr ( 'placeholder' , '步长' ) ;
287
- $ ( '.input-group:eq(2)>span' ) . text ( '请输入半径 ' ) ; //半径
288
- $ ( '.input-group:eq(2)>input' ) . attr ( 'placeholder' , '半径' ) ;
281
+ $ ( '.input-group:eq(1)>span' ) . text ( '步长 ' ) ; //步长
282
+ $ ( '.input-group:eq(1)>input' ) . unbind ( 'focusout' ) . val ( "1" ) ;
283
+ $ ( '.input-group:eq(2)>span' ) . text ( '半径 ' ) ; //半径
284
+ $ ( '.input-group:eq(2)>input' ) . val ( "10" ) ;
289
285
$ ( '#calc' ) . val ( '生成标记点缓冲区' ) ;
290
286
}
291
287
else if ( choose === 'circle' ) {
@@ -302,17 +298,16 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
302
298
$ ( '.input-group:eq(1)' ) . show ( ) ; //步长
303
299
$ ( '.input-group:eq(2)' ) . show ( ) ; //半径
304
300
$ ( '.input-group:eq(3)' ) . show ( ) ;
305
- $ ( '.input-group:eq(1)>span' ) . text ( '请输入步长 ' ) ; //步长
306
- $ ( '.input-group:eq(1)>input' ) . unbind ( 'focusout' ) . attr ( 'placeholder' , '步长' ) ;
307
- $ ( '.input-group:eq(2)>span' ) . text ( '请输入半径 ' ) ; //半径
308
- $ ( '.input-group:eq(2)>input' ) . attr ( 'placeholder' , '半径' ) ;
301
+ $ ( '.input-group:eq(1)>span' ) . text ( '步长 ' ) ; //步长
302
+ $ ( '.input-group:eq(1)>input' ) . unbind ( 'focusout' ) . val ( "10" ) ;
303
+ $ ( '.input-group:eq(2)>span' ) . text ( '半径 ' ) ; //半径
304
+ $ ( '.input-group:eq(2)>input' ) . val ( "10" ) ;
309
305
$ ( '#calc' ) . val ( '生成圆多边形' ) ;
310
306
}
311
307
else {
312
308
widgets . alert . showAlert ( '方法不存在' , false ) ;
313
309
}
314
310
showPanel ( ) ;
315
- }
316
311
} ) ;
317
312
318
313
@@ -538,7 +533,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
538
533
function reset ( ) {
539
534
$ ( '.chooseItems' ) . show ( ) ;
540
535
hidePanel ( ) ;
541
- $ ( '.panel-heading>h5' ) . text ( 'turf测量 ' ) ;
536
+ $ ( '.panel-heading>h5' ) . text ( '测量 ' ) ;
542
537
$ ( '#unitSelect option:first' ) . prop ( "selected" , 'selected' ) ;
543
538
$ ( '#distance' ) . val ( '' ) ;
544
539
$ ( '#bearing' ) . val ( '' ) ;
@@ -625,6 +620,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
625
620
626
621
//turf along方法
627
622
function along ( ) {
623
+ var unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
628
624
if ( unit != 'null' && unit != undefined ) {
629
625
if ( checkIsNum ( distance ) && coordinate ) {
630
626
turfLayer . process ( "Helper.lineString" , {
@@ -682,6 +678,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
682
678
683
679
//turf destination方法
684
680
function destination ( ) {
681
+ var unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
685
682
if ( unit != 'null' && unit != undefined ) {
686
683
widgets . alert . clearAlert ( ) ;
687
684
if ( checkIsNum ( distance ) && isInRange ( bearing ) ) {
@@ -714,6 +711,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
714
711
"角度" : "degrees" ,
715
712
"弧度" : "radians" ,
716
713
} ;
714
+ var unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
717
715
if ( unit != 'null' && unit != undefined ) {
718
716
resultLayer . process ( "Measurement.distance" , {
719
717
"from" : turfLayer . toGeoJSON ( ) . features [ 0 ] . geometry . coordinates [ 0 ] ,
@@ -814,6 +812,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
814
812
//turf buffer
815
813
//先draw一个点 再在此点上进行缓冲区分析,默认单位killo
816
814
function buffer ( ) {
815
+ var unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
817
816
if ( unit != 'null' ) {
818
817
widgets . alert . clearAlert ( ) ;
819
818
greatThanZero ( steps ) ;
@@ -842,6 +841,7 @@ <h5 class='panel-title text-center'>京深路卧龙岗隧道路段</h5>
842
841
//先draw一个点 再在此点上画圆多边形
843
842
//有默认单位kilometer
844
843
function circle ( ) {
844
+ var unit = $ ( '#unitSelect' ) . children ( 'option:selected' ) . val ( ) ;
845
845
widgets . alert . clearAlert ( ) ;
846
846
greatThanZero ( steps ) ;
847
847
if ( coordinate && checkIsNum ( distance ) && checkIsNum ( radius ) && steps > 0 ) {
0 commit comments