@@ -19,7 +19,10 @@ import { geoJsonStyleFunction } from './Styles'
19
19
import { applyBackground , applyStyle } from 'ol-mapbox-style' ;
20
20
import UndoRedo from 'ol-ext/interaction/UndoRedo'
21
21
import EsriPBF from "./EsriPBF.js" ;
22
+ import EsriJSON from 'ol/format/EsriJSON.js' ;
22
23
import { createStyleFunctionFromUrl } from 'ol-esri-styles' ;
24
+ import { tile as tileStrategy } from 'ol/loadingstrategy.js' ;
25
+ import { createXYZ } from 'ol/tilegrid.js' ;
23
26
24
27
/**
25
28
* Creates and returns an OpenLayers layer instance for the given layer configuration object.
@@ -308,13 +311,78 @@ export function createLayer(layerConfig, map) {
308
311
) +
309
312
'&geometryType=esriGeometryEnvelope&inSR=3857&outFields=*&resultType=tile' +
310
313
'&outSR=3857' ,
314
+ strategy : tileStrategy (
315
+ createXYZ ( {
316
+ tileSize : [ 512 , 512 ] ,
317
+ } ) ,
318
+ ) ,
311
319
} ) ,
312
320
} )
313
321
createStyleFunctionFromUrl ( layerConfig . source . url , map . getView ( ) . getProjection ( ) || 'EPSG:3857' ) . then ( styleFunction => {
314
- esriVectorTiles . setStyle ( styleFunction )
315
- console . log ( styleFunction ) ;
322
+ esriVectorTiles . setStyle ( styleFunction ) ;
316
323
} ) ;
317
324
return esriVectorTiles ;
325
+ case 'arcgis-feature-service' :
326
+ const esriFeatureService = new VectorLayer ( {
327
+ name : layerConfig . label ,
328
+ title : layerConfig . title || layerConfig . name ,
329
+ minZoom : layerConfig . minZoom ,
330
+ maxZoom : layerConfig . maxZoom ,
331
+ visible : layerConfig . visible ,
332
+ opacity : layerConfig . opacity ,
333
+ selectable : layerConfig . selectable ,
334
+ groups : layerConfig . groups ,
335
+ extra : layerConfig . extra ,
336
+ order : layerConfig . order ,
337
+ splitscreen : layerConfig . splitscreen ,
338
+ displayInLayerSwitcher : layerConfig . userVisible ,
339
+ source : new VectorSource ( {
340
+ format : new EsriJSON ( ) ,
341
+ url : function ( extent , resolution , projection ) {
342
+ // ArcGIS Server only wants the numeric portion of the projection ID.
343
+ const srid = projection
344
+ . getCode ( )
345
+ . split ( / : (? = \d + $ ) / )
346
+ . pop ( ) ;
347
+
348
+ const url =
349
+ layerConfig . source . url +
350
+ '/query/?f=json&' +
351
+ 'returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometry=' +
352
+ encodeURIComponent (
353
+ '{"xmin":' +
354
+ extent [ 0 ] +
355
+ ',"ymin":' +
356
+ extent [ 1 ] +
357
+ ',"xmax":' +
358
+ extent [ 2 ] +
359
+ ',"ymax":' +
360
+ extent [ 3 ] +
361
+ ',"spatialReference":{"wkid":' +
362
+ srid || '3857' +
363
+ '}}' ,
364
+ ) +
365
+ '&geometryType=esriGeometryEnvelope&inSR=' +
366
+ srid || '3857' +
367
+ '&outFields=*' +
368
+ '&outSR=' +
369
+ srid || '3857' ;
370
+
371
+ return url ;
372
+ } ,
373
+ strategy : tileStrategy (
374
+ createXYZ ( {
375
+ tileSize : [ 512 , 512 ] ,
376
+ } ) ,
377
+ ) ,
378
+ } )
379
+ } ) ;
380
+ createStyleFunctionFromUrl ( "https://services-eu1.arcgis.com/NPIbx47lsIiu2pqz/ArcGIS/rest/services/Neptune_Coastline_Campaign_Open_Data_Land_Use_2014/FeatureServer/0" , map . getView ( ) . getProjection ( ) || 'EPSG:3857' ) . then ( styleFunction => {
381
+ esriFeatureService . setStyle ( styleFunction ) ;
382
+ } ) ;
383
+
384
+ return esriFeatureService ;
385
+
318
386
319
387
/* History ?
320
388
new ol.layer.Geoportail({
0 commit comments