@@ -65,6 +65,11 @@ ArcGIS.prototype.init = function init($el) {
65
65
"esri/tasks/FindTask" ,
66
66
"esri/tasks/FindParameters" ,
67
67
"esri/renderers/HeatmapRenderer" ,
68
+ "esri/config" , // 所有JS API配置选项的默认值。
69
+ "esri/tasks/GeometryService" ,
70
+ "esri/Color" ,
71
+ "esri/tasks/BufferParameters" ,
72
+ "esri/geometry/normalizeUtils" ,
68
73
"dojo/on" , // dojo 事件监听
69
74
// -----------------------
70
75
// "dojo/dom-construct",
@@ -100,6 +105,11 @@ ArcGIS.prototype.init = function init($el) {
100
105
FindTask , // FindTask 属性查询
101
106
FindParameters , // FindTask 属性查询参数
102
107
HeatmapRenderer , // 热力图渲染
108
+ EsriConfig , // 所有JS API配置选项的默认值。
109
+ GeometryService , // 表示由ArcGIS服务器REST API公开的几何图形服务资源。它用于对几何图形执行各种操作,如项目、简化、缓冲区和关系。
110
+ EsriColor , // 设置颜色
111
+ BufferParameters , // 缓冲区参数配置模块
112
+ NormalizeUtils ,
103
113
dojoOn , // dojo 事件监听
104
114
] ) => {
105
115
this . SpatialReference = SpatialReference ;
@@ -119,6 +129,9 @@ ArcGIS.prototype.init = function init($el) {
119
129
this . QueryTask = QueryTask ;
120
130
// 热力图渲染
121
131
this . HeatmapRenderer = HeatmapRenderer ;
132
+ // 所有JS API配置选项的默认值。
133
+ this . EsriConfig = EsriConfig ;
134
+ this . GeometryService = GeometryService ;
122
135
// dojo
123
136
this . dojoOn = dojoOn ;
124
137
@@ -195,31 +208,135 @@ ArcGIS.prototype.init = function init($el) {
195
208
this . map . onLoad ( ) ;
196
209
// thatMap.on("Click", mapClick);
197
210
211
+ let toolBar ;
212
+ // 得使用 ;function 定义函数
213
+ function dddddd ( evtObj ) {
214
+ console . log ( evtObj ) ;
215
+ }
216
+
198
217
function mapReady ( ) {
199
- console . log ( 1 ) ;
218
+ console . log ( "地图加载完成" ) ;
200
219
201
- let doctorNumFlayer = new FeatureLayer (
202
- serverUrl ( ) . fenxi . xiangcunyisheng + "/0" ,
203
- {
204
- outFields : [ "*" ] , //必须要有返回值,提供给热力图进行分析
205
- }
220
+ // 配置缓冲区参数
221
+ EsriConfig . defaults . geometryService = new GeometryService (
222
+ serverUrl ( ) . Utilities . Geometry
206
223
) ;
224
+ EsriConfig . defaults . io . proxyUrl = "/proxy/" ;
225
+ EsriConfig . defaults . io . alwaysUseProxy = false ;
207
226
208
- let heatmapRenderer = new HeatmapRenderer ( {
209
- field : "yiliao" , // 根据哪一个字段进行渲染
210
- blurRadius : 12 , //蓝色
211
- colors : [
212
- "rgba(30,144,255, 0)" ,
213
- "rgba(30,144,255,0.8)" ,
214
- "rgb(0, 255, 0)" ,
215
- "rgb(255, 255, 0)" ,
216
- "rgb(255, 0, 0)" ,
217
- ] ,
218
- } ) ;
219
- doctorNumFlayer . setRenderer ( heatmapRenderer ) ;
227
+ // 定义一个绘图工具
228
+ toolBar = new Draw ( that . map ) ;
229
+ toolBar . activate ( Draw . CIRCLE ) ;
230
+ toolBar . on ( "draw-complete" , nongyecompany ) ;
231
+ }
220
232
221
- that . map . addLayer ( doctorNumFlayer ) ; // 将热力图分析添加到地图上
233
+ function nongyecompany ( evtObj ) {
234
+ //对弹窗进行判断
235
+ var geometry = evtObj . geometry ;
236
+ var symbol ;
237
+ // symbol;
238
+ switch ( geometry . type ) {
239
+ case "point" :
240
+ symbol = new SimpleMarkerSymbol (
241
+ SimpleMarkerSymbol . STYLE_SQUARE ,
242
+ 10 ,
243
+ new SimpleLineSymbol (
244
+ SimpleLineSymbol . STYLE_SOLID ,
245
+ new EsriColor ( [ 255 , 0 , 0 ] ) ,
246
+ 1
247
+ ) ,
248
+ new EsriColor ( [ 0 , 255 , 0 , 0.25 ] )
249
+ ) ;
250
+ break ;
251
+ case "polyline" :
252
+ symbol = new SimpleLineSymbol (
253
+ SimpleLineSymbol . STYLE_DASH ,
254
+ new EsriColor ( [ 255 , 0 , 0 ] ) ,
255
+ 1
256
+ ) ;
257
+ break ;
258
+ case "polygon" :
259
+ symbol = new SimpleFillSymbol (
260
+ SimpleFillSymbol . STYLE_NONE ,
261
+ new SimpleLineSymbol (
262
+ SimpleLineSymbol . STYLE_DASHDOT ,
263
+ new EsriColor ( [ 255 , 0 , 0 ] ) ,
264
+ 2
265
+ ) ,
266
+ new EsriColor ( [ 255 , 255 , 0 , 0.25 ] )
267
+ ) ;
268
+ break ;
269
+ }
270
+ var graphic = new Graphic ( geometry , symbol ) ;
271
+ that . map . graphics . add ( graphic ) ;
272
+
273
+ var params = new BufferParameters ( ) ;
274
+ params . distances = [ "10" ] ;
275
+ params . bufferSpatialReference = new SpatialReference ( {
276
+ wkid : 102100 ,
277
+ } ) ;
278
+ params . outSpatialReference = that . map . spatialReference ;
279
+ params . unit = GeometryService [ "UNIT_KILOMETER" ] ;
280
+ NormalizeUtils . normalizeCentralMeridian ( [ geometry ] ) . then ( function (
281
+ normalizedGeometries
282
+ ) {
283
+ var normalizedGeometry = normalizedGeometries [ 0 ] ;
284
+ if ( normalizedGeometry . type === "polygon" ) {
285
+ EsriConfig . defaults . geometryService . simplify (
286
+ [ normalizedGeometry ] ,
287
+ function ( geometries ) {
288
+ params . geometries = geometries ;
289
+ EsriConfig . defaults . geometryService . buffer (
290
+ params ,
291
+ showBuffer1
292
+ ) ;
293
+ }
294
+ ) ;
295
+ } else {
296
+ params . geometries = [ normalizedGeometry ] ;
297
+ EsriConfig . defaults . geometryService . buffer ( params , showBuffer1 ) ;
298
+ }
299
+ } ) ;
222
300
}
301
+
302
+ let showBuffer1 = ( bufferedGeometries ) => {
303
+ // var symbol = new SimpleFillSymbol(
304
+ // SimpleFillSymbol.STYLE_SOLID,
305
+ // new SimpleLineSymbol(
306
+ // SimpleLineSymbol.STYLE_SOLID,
307
+ // new EsriColor([255, 0, 0, 0.65]),
308
+ // 2
309
+ // ),
310
+ // new EsriColor([255, 0, 0, 0.35])
311
+ // );
312
+
313
+ console . log ( ) ;
314
+ const geometries = bufferedGeometries [ 0 ] . rings [ 0 ] ;
315
+ console . log ( geometries ) ;
316
+ console . log ( that . map ) ;
317
+
318
+ geometries . forEach ( function ( geometry ) {
319
+ console . log ( geometry ) ;
320
+
321
+ let graphicBuffer = geometry ;
322
+ var BufferTask = QueryTask (
323
+ serverUrl ( ) . huinong . zhongzhiBuffer + "/0"
324
+ ) ;
325
+ var Bufferquery = new Query ( ) ;
326
+ Bufferquery . returnGeometry = true ;
327
+ // var sr1 = new SpatialReference(4490);
328
+ graphicBuffer . spatialReference = new SpatialReference ( 4490 ) ;
329
+ Bufferquery . geometry = graphicBuffer ;
330
+ // Bufferquery.geometry = graphicBuffer.setSpatialReference(sr1);
331
+ Bufferquery . outFields = [ "*" ] ;
332
+ BufferTask . execute ( Bufferquery , showResults ) ;
333
+ } ) ;
334
+
335
+ function showResults ( featureSet ) {
336
+ that . map . graphics . clear ( ) ;
337
+ console . log ( featureSet ) ;
338
+ }
339
+ } ;
223
340
}
224
341
) //end
225
342
. catch ( ( err ) => {
0 commit comments