esrieact 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +309 -0
- package/dist/core/Graphic.d.ts +16 -0
- package/dist/core/Graphic.js +67 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +3 -0
- package/dist/core/renderers/Renderer.d.ts +11 -0
- package/dist/core/renderers/Renderer.js +11 -0
- package/dist/core/renderers/SimpleRenderer.d.ts +11 -0
- package/dist/core/renderers/SimpleRenderer.js +12 -0
- package/dist/core/renderers/UniqueValueRenderer.d.ts +12 -0
- package/dist/core/renderers/UniqueValueRenderer.js +12 -0
- package/dist/core/renderers/createRendererComponent.d.ts +13 -0
- package/dist/core/renderers/createRendererComponent.js +63 -0
- package/dist/core/renderers/index.d.ts +4 -0
- package/dist/core/renderers/index.js +4 -0
- package/dist/core/symbols/PictureMarkerSymbol.d.ts +9 -0
- package/dist/core/symbols/PictureMarkerSymbol.js +43 -0
- package/dist/core/symbols/SimpleFillSymbol.d.ts +9 -0
- package/dist/core/symbols/SimpleFillSymbol.js +34 -0
- package/dist/core/symbols/index.d.ts +2 -0
- package/dist/core/symbols/index.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/layers/FeatureLayer.d.ts +27 -0
- package/dist/layers/FeatureLayer.js +13 -0
- package/dist/layers/GraphicsLayer.d.ts +14 -0
- package/dist/layers/GraphicsLayer.js +13 -0
- package/dist/layers/GroupLayer.d.ts +14 -0
- package/dist/layers/GroupLayer.js +30 -0
- package/dist/layers/ImageryLayer.d.ts +14 -0
- package/dist/layers/ImageryLayer.js +13 -0
- package/dist/layers/ImageryTileLayer.d.ts +14 -0
- package/dist/layers/ImageryTileLayer.js +13 -0
- package/dist/layers/KMLLayer.d.ts +14 -0
- package/dist/layers/KMLLayer.js +13 -0
- package/dist/layers/LayerView.d.ts +52 -0
- package/dist/layers/LayerView.js +70 -0
- package/dist/layers/VectorTileLayer.d.ts +14 -0
- package/dist/layers/VectorTileLayer.js +13 -0
- package/dist/layers/WMSLayer.d.ts +14 -0
- package/dist/layers/WMSLayer.js +13 -0
- package/dist/layers/WebTileLayer.d.ts +14 -0
- package/dist/layers/WebTileLayer.js +13 -0
- package/dist/layers/createLayerComponent.d.ts +36 -0
- package/dist/layers/createLayerComponent.js +54 -0
- package/dist/layers/index.d.ts +11 -0
- package/dist/layers/index.js +11 -0
- package/dist/map/MapView.d.ts +144 -0
- package/dist/map/MapView.js +109 -0
- package/dist/map/index.d.ts +1 -0
- package/dist/map/index.js +1 -0
- package/dist/symbols/SymbolPreview.d.ts +16 -0
- package/dist/symbols/SymbolPreview.js +21 -0
- package/dist/symbols/index.d.ts +1 -0
- package/dist/symbols/index.js +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +30 -0
- package/dist/utils/useEsriPropertyUpdates.d.ts +10 -0
- package/dist/utils/useEsriPropertyUpdates.js +26 -0
- package/dist/utils/useEvents.d.ts +20 -0
- package/dist/utils/useEvents.js +38 -0
- package/dist/utils/usePrevious.d.ts +2 -0
- package/dist/utils/usePrevious.js +9 -0
- package/dist/widgets/BasemapGallery.d.ts +14 -0
- package/dist/widgets/BasemapGallery.js +13 -0
- package/dist/widgets/Expand.d.ts +14 -0
- package/dist/widgets/Expand.js +15 -0
- package/dist/widgets/LayerList/ListItem.d.ts +14 -0
- package/dist/widgets/LayerList/ListItem.js +13 -0
- package/dist/widgets/LayerList/index.d.ts +14 -0
- package/dist/widgets/LayerList/index.js +13 -0
- package/dist/widgets/Legend.d.ts +14 -0
- package/dist/widgets/Legend.js +15 -0
- package/dist/widgets/SearchBar.d.ts +14 -0
- package/dist/widgets/SearchBar.js +13 -0
- package/dist/widgets/Sketch.d.ts +24 -0
- package/dist/widgets/Sketch.js +13 -0
- package/dist/widgets/createWidgetComponent.d.ts +29 -0
- package/dist/widgets/createWidgetComponent.js +47 -0
- package/dist/widgets/index.d.ts +7 -0
- package/dist/widgets/index.js +7 -0
- package/package.json +39 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext, useImperativeHandle, useMemo } from "react";
|
|
2
|
+
import EsriSimpleFillSymbol from "@arcgis/core/symbols/SimpleFillSymbol";
|
|
3
|
+
import Graphic from "@arcgis/core/Graphic";
|
|
4
|
+
import Renderer from "@arcgis/core/renderers/Renderer";
|
|
5
|
+
import { GraphicContext } from "../Graphic";
|
|
6
|
+
import { useEsriPropertyUpdates } from "../../utils";
|
|
7
|
+
/**
|
|
8
|
+
* A SimpleFillSymbol component, must be rendered as a child of a Renderer component or Graphic component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html)
|
|
12
|
+
*/
|
|
13
|
+
export const SimpleFillSymbol = React.forwardRef((properties, ref) => {
|
|
14
|
+
const parent = useContext(GraphicContext);
|
|
15
|
+
/**
|
|
16
|
+
* Create instance only on first mount
|
|
17
|
+
*/
|
|
18
|
+
const instance = useMemo(() => {
|
|
19
|
+
const symbol = new EsriSimpleFillSymbol(properties);
|
|
20
|
+
if (!(parent instanceof Graphic) || !(parent instanceof Renderer)) {
|
|
21
|
+
// Allow this because it only happens in development and is helpful for devs
|
|
22
|
+
// eslint-disable-next-line
|
|
23
|
+
console.error("You are trying to render a SimpleFillSymbol component that is not a descendant of a Graphic or Renderer.", "Did you forget to wrap your SimpleFillSymbol in a Graphic or Renderer?");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (parent) {
|
|
27
|
+
parent.symbol = symbol;
|
|
28
|
+
}
|
|
29
|
+
return symbol;
|
|
30
|
+
}, []);
|
|
31
|
+
useImperativeHandle(ref, () => instance);
|
|
32
|
+
useEsriPropertyUpdates(instance, properties);
|
|
33
|
+
return null;
|
|
34
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriFeatureLayer from "@arcgis/core/layers/FeatureLayer";
|
|
3
|
+
export type FeatureLayerEventHandlerFnMap = Partial<{
|
|
4
|
+
refresh: __esri.FeatureLayerRefreshEventHandler;
|
|
5
|
+
edits: __esri.FeatureLayerEditsEventHandler;
|
|
6
|
+
"layerview-create": __esri.FeatureLayerLayerviewCreateEventHandler;
|
|
7
|
+
"layerview-create-error": __esri.FeatureLayerLayerviewCreateErrorEventHandler;
|
|
8
|
+
"layerview-destroy": __esri.FeatureLayerLayerviewDestroyEventHandler;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* A FeatureLayer component
|
|
12
|
+
*
|
|
13
|
+
* ArcGIS JS API Source Components:
|
|
14
|
+
* - [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html)
|
|
15
|
+
*/
|
|
16
|
+
export declare const FeatureLayer: React.ForwardRefExoticComponent<__esri.FeatureLayerProperties & {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
} & {
|
|
19
|
+
events?: Partial<{
|
|
20
|
+
refresh: __esri.FeatureLayerRefreshEventHandler;
|
|
21
|
+
edits: __esri.FeatureLayerEditsEventHandler;
|
|
22
|
+
"layerview-create": __esri.FeatureLayerLayerviewCreateEventHandler;
|
|
23
|
+
"layerview-create-error": __esri.FeatureLayerLayerviewCreateErrorEventHandler;
|
|
24
|
+
"layerview-destroy": __esri.FeatureLayerLayerviewDestroyEventHandler;
|
|
25
|
+
}> | undefined;
|
|
26
|
+
layerOrder?: number | undefined;
|
|
27
|
+
} & React.RefAttributes<EsriFeatureLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriFeatureLayer from "@arcgis/core/layers/FeatureLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriFeatureLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A FeatureLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const FeatureLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriGraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
|
|
3
|
+
/**
|
|
4
|
+
* A GraphicsLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const GraphicsLayer: React.ForwardRefExoticComponent<__esri.GraphicsLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriGraphicsLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriGraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriGraphicsLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A GraphicsLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const GraphicsLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriGroupLayer from "@arcgis/core/layers/GroupLayer";
|
|
3
|
+
/**
|
|
4
|
+
* A GroupLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const GroupLayer: React.ForwardRefExoticComponent<__esri.GroupLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriGroupLayer>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// /**
|
|
2
|
+
// * The react context object that any layer component creates when rendered
|
|
3
|
+
// * and makes available to its descendants
|
|
4
|
+
// */
|
|
5
|
+
// export const GroupLayerContext = createContext({} as EsriGroupLayer);
|
|
6
|
+
// type GroupLayerProps = __esri.GroupLayerProperties & React.PropsWithChildren;
|
|
7
|
+
// export const GroupLayer = React.forwardRef<EsriGroupLayer, GroupLayerProps>(
|
|
8
|
+
// ({ children, ...properties }, ref) => {
|
|
9
|
+
// // If no children, there is no need to render a context provider
|
|
10
|
+
// if (!children) return null;
|
|
11
|
+
// return (
|
|
12
|
+
// <GroupLayerContext.Provider value={instance}>
|
|
13
|
+
// {children}
|
|
14
|
+
// </GroupLayerContext.Provider>
|
|
15
|
+
// );
|
|
16
|
+
// },
|
|
17
|
+
// );
|
|
18
|
+
import React from "react";
|
|
19
|
+
import EsriGroupLayer from "@arcgis/core/layers/GroupLayer";
|
|
20
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
21
|
+
const createLayer = (properties) => {
|
|
22
|
+
return new EsriGroupLayer(properties);
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A GroupLayer component
|
|
26
|
+
*
|
|
27
|
+
* ArcGIS JS API Source Components:
|
|
28
|
+
* - [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html)
|
|
29
|
+
*/
|
|
30
|
+
export const GroupLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriImageryLayer from "@arcgis/core/layers/ImageryLayer";
|
|
3
|
+
/**
|
|
4
|
+
* An ImageryLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const ImageryLayer: React.ForwardRefExoticComponent<__esri.ImageryLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriImageryLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriImageryLayer from "@arcgis/core/layers/ImageryLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriImageryLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* An ImageryLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const ImageryLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriImageryTileLayer from "@arcgis/core/layers/ImageryTileLayer";
|
|
3
|
+
/**
|
|
4
|
+
* An ImageryTileLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const ImageryTileLayer: React.ForwardRefExoticComponent<__esri.ImageryTileLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriImageryTileLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriImageryTileLayer from "@arcgis/core/layers/ImageryTileLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriImageryTileLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* An ImageryTileLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const ImageryTileLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriKMLLayer from "@arcgis/core/layers/KMLLayer";
|
|
3
|
+
/**
|
|
4
|
+
* A KMLLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [KMLLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-kml/)
|
|
8
|
+
*/
|
|
9
|
+
export declare const KMLLayer: React.ForwardRefExoticComponent<__esri.KMLLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriKMLLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriKMLLayer from "@arcgis/core/layers/KMLLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriKMLLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A KMLLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [KMLLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-kml/)
|
|
12
|
+
*/
|
|
13
|
+
export const KMLLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Generic function to create a layer view component. Can create a react-wrapped LayerView. Any component
|
|
4
|
+
* created from this function must be used as a child of a Layer that has a layer view, i.e. `view.whenLayerView(layer)` can
|
|
5
|
+
* be called on that layer. Can be casted to specify what kind of LayerView and LayerViewProps are being referred to by
|
|
6
|
+
* the parent layer component
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // defaults to basic esri LayerView, not very useful
|
|
10
|
+
* const LayerView = createLayerViewComponent();
|
|
11
|
+
*
|
|
12
|
+
* const SomeComponent = () => {
|
|
13
|
+
* return (
|
|
14
|
+
* <Layer>
|
|
15
|
+
* <LayerView />
|
|
16
|
+
* </Layer>
|
|
17
|
+
* )
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // More specific casting for a specific type of Layer, i.e. a FeatureLayer
|
|
22
|
+
* const FeatureLayerView = createLayerViewComponent<FeatureLayerViewProperties, FeatureLayerView>();
|
|
23
|
+
*
|
|
24
|
+
* const SomeComponent = () => {
|
|
25
|
+
* return (
|
|
26
|
+
* <FeatureLayer>
|
|
27
|
+
* <FeatureLayerView
|
|
28
|
+
* // Filter property of FeatureLayerView recognized
|
|
29
|
+
* filter={{ where: 'SOME SQL CLAUSE' }}
|
|
30
|
+
* />
|
|
31
|
+
* </FeatureLayer>
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
*/
|
|
35
|
+
export declare function createLayerViewComponent<P extends __esri.LayerViewProperties, R extends __esri.LayerView>(): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<R>>;
|
|
36
|
+
/**
|
|
37
|
+
* Generic LayerView component for the layerView of any generic Layer, can be child of
|
|
38
|
+
* any Layer that has a layerView
|
|
39
|
+
*/
|
|
40
|
+
export declare const LayerView: React.ForwardRefExoticComponent<__esri.LayerViewProperties & React.RefAttributes<__esri.LayerView>>;
|
|
41
|
+
/**
|
|
42
|
+
* FeatureLayerView component, must be child of FeatureLayer component
|
|
43
|
+
*/
|
|
44
|
+
export declare const FeatureLayerView: React.ForwardRefExoticComponent<__esri.FeatureLayerViewProperties & React.RefAttributes<__esri.FeatureLayerView>>;
|
|
45
|
+
/**
|
|
46
|
+
* KLMLayerView component, must be child of KLMLayer component
|
|
47
|
+
*/
|
|
48
|
+
export declare const KLMLayerView: React.ForwardRefExoticComponent<__esri.KMLLayerViewProperties & React.RefAttributes<__esri.KMLLayerView>>;
|
|
49
|
+
/**
|
|
50
|
+
* CSVLayerView component, must be child of CSVLayer component
|
|
51
|
+
*/
|
|
52
|
+
export declare const CSVLayerView: React.ForwardRefExoticComponent<__esri.CSVLayerViewProperties & React.RefAttributes<__esri.CSVLayerView>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { forwardRef, useContext, useEffect, useImperativeHandle, useState, } from "react";
|
|
2
|
+
import { LayerContext } from "./createLayerComponent";
|
|
3
|
+
import { useMap } from "..";
|
|
4
|
+
import { useEsriPropertyUpdates } from "../utils";
|
|
5
|
+
/**
|
|
6
|
+
* Generic function to create a layer view component. Can create a react-wrapped LayerView. Any component
|
|
7
|
+
* created from this function must be used as a child of a Layer that has a layer view, i.e. `view.whenLayerView(layer)` can
|
|
8
|
+
* be called on that layer. Can be casted to specify what kind of LayerView and LayerViewProps are being referred to by
|
|
9
|
+
* the parent layer component
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // defaults to basic esri LayerView, not very useful
|
|
13
|
+
* const LayerView = createLayerViewComponent();
|
|
14
|
+
*
|
|
15
|
+
* const SomeComponent = () => {
|
|
16
|
+
* return (
|
|
17
|
+
* <Layer>
|
|
18
|
+
* <LayerView />
|
|
19
|
+
* </Layer>
|
|
20
|
+
* )
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // More specific casting for a specific type of Layer, i.e. a FeatureLayer
|
|
25
|
+
* const FeatureLayerView = createLayerViewComponent<FeatureLayerViewProperties, FeatureLayerView>();
|
|
26
|
+
*
|
|
27
|
+
* const SomeComponent = () => {
|
|
28
|
+
* return (
|
|
29
|
+
* <FeatureLayer>
|
|
30
|
+
* <FeatureLayerView
|
|
31
|
+
* // Filter property of FeatureLayerView recognized
|
|
32
|
+
* filter={{ where: 'SOME SQL CLAUSE' }}
|
|
33
|
+
* />
|
|
34
|
+
* </FeatureLayer>
|
|
35
|
+
* )
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
export function createLayerViewComponent() {
|
|
39
|
+
return forwardRef(function LayerViewCore(props, ref) {
|
|
40
|
+
const { view } = useMap();
|
|
41
|
+
const layer = useContext(LayerContext);
|
|
42
|
+
const [layerView, setLayerView] = useState();
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
view.whenLayerView(layer).then((layerView) => {
|
|
45
|
+
setLayerView(layerView);
|
|
46
|
+
Object.keys(props).forEach((property) => (layerView[property] = props[property]));
|
|
47
|
+
});
|
|
48
|
+
}, []);
|
|
49
|
+
useEsriPropertyUpdates(layerView, props);
|
|
50
|
+
useImperativeHandle(ref, () => layerView);
|
|
51
|
+
return null;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generic LayerView component for the layerView of any generic Layer, can be child of
|
|
56
|
+
* any Layer that has a layerView
|
|
57
|
+
*/
|
|
58
|
+
export const LayerView = createLayerViewComponent();
|
|
59
|
+
/**
|
|
60
|
+
* FeatureLayerView component, must be child of FeatureLayer component
|
|
61
|
+
*/
|
|
62
|
+
export const FeatureLayerView = createLayerViewComponent();
|
|
63
|
+
/**
|
|
64
|
+
* KLMLayerView component, must be child of KLMLayer component
|
|
65
|
+
*/
|
|
66
|
+
export const KLMLayerView = createLayerViewComponent();
|
|
67
|
+
/**
|
|
68
|
+
* CSVLayerView component, must be child of CSVLayer component
|
|
69
|
+
*/
|
|
70
|
+
export const CSVLayerView = createLayerViewComponent();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriVectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
3
|
+
/**
|
|
4
|
+
* A VectorTileLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const VectorTileLayer: React.ForwardRefExoticComponent<__esri.VectorTileLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriVectorTileLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriVectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriVectorTileLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A VectorTileLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const VectorTileLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriWMSLayer from "@arcgis/core/layers/WMSLayer";
|
|
3
|
+
/**
|
|
4
|
+
* A WMS Layer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const WMSLayer: React.ForwardRefExoticComponent<__esri.WMSLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriWMSLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriWMSLayer from "@arcgis/core/layers/WMSLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriWMSLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A WMS Layer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const WMSLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriWebTileLayer from "@arcgis/core/layers/WebTileLayer";
|
|
3
|
+
/**
|
|
4
|
+
* An WebTileLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const WebTileLayer: React.ForwardRefExoticComponent<__esri.WebTileLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriWebTileLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriWebTileLayer from "@arcgis/core/layers/WebTileLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriWebTileLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* An WebTileLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const WebTileLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { Ref } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The react context object that any layer component creates when rendered
|
|
4
|
+
* and makes available to its descendants
|
|
5
|
+
*/
|
|
6
|
+
export declare const LayerContext: React.Context<__esri.Layer | __esri.GroupLayer>;
|
|
7
|
+
/**
|
|
8
|
+
* Event handlers for all Layer components, some layer components may extend from this
|
|
9
|
+
*/
|
|
10
|
+
export interface LayerEventHandlerFnMap {
|
|
11
|
+
"layerview-create": __esri.FeatureLayerLayerviewCreateEventHandler;
|
|
12
|
+
"layerview-create-error": __esri.FeatureLayerLayerviewCreateErrorEventHandler;
|
|
13
|
+
"layerview-destroy": __esri.FeatureLayerLayerviewDestroyEventHandler;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Properties that can be applied to any ESRIEACT Layer component. Extends from
|
|
17
|
+
* esri's LayerProperties to include child components (i.e. in the case of GroupLayers)
|
|
18
|
+
*/
|
|
19
|
+
export type LayerComponentProps<T extends __esri.LayerProperties = __esri.LayerProperties, E extends Partial<LayerEventHandlerFnMap> = {}> = React.PropsWithChildren<T> & {
|
|
20
|
+
events?: E;
|
|
21
|
+
layerOrder?: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Function that takes in layer properties and returns an esri Layer instance. Properties must be
|
|
25
|
+
* any esri properties that extend esri.LayerProperties, and optional children
|
|
26
|
+
*/
|
|
27
|
+
export type CreateLayerFunction<T extends LayerComponentProps> = (properties: T) => __esri.Layer;
|
|
28
|
+
/**
|
|
29
|
+
* Factory function to create an esrieact layer component
|
|
30
|
+
* @param createLayer Function that takes in the layer properties (which must extend from __esri.LayerProperties)
|
|
31
|
+
* and returns the layer instance
|
|
32
|
+
* @param ref The react ref to be passed from the parent
|
|
33
|
+
* @param properties The layer properties
|
|
34
|
+
* @returns A context provider whose context is the instance to be passed to children, or if there are no children, returns null
|
|
35
|
+
*/
|
|
36
|
+
export declare const createLayerComponent: (createLayer: CreateLayerFunction<LayerComponentProps>, ref: Ref<__esri.Layer>, { children, events, layerOrder, ...properties }: LayerComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useImperativeHandle, useMemo, } from "react";
|
|
3
|
+
import { useMap } from "../map/MapView";
|
|
4
|
+
import { useEsriPropertyUpdates, useEvents } from "../utils";
|
|
5
|
+
/**
|
|
6
|
+
* The react context object that any layer component creates when rendered
|
|
7
|
+
* and makes available to its descendants
|
|
8
|
+
*/
|
|
9
|
+
export const LayerContext = createContext({});
|
|
10
|
+
/**
|
|
11
|
+
* Factory function to create an esrieact layer component
|
|
12
|
+
* @param createLayer Function that takes in the layer properties (which must extend from __esri.LayerProperties)
|
|
13
|
+
* and returns the layer instance
|
|
14
|
+
* @param ref The react ref to be passed from the parent
|
|
15
|
+
* @param properties The layer properties
|
|
16
|
+
* @returns A context provider whose context is the instance to be passed to children, or if there are no children, returns null
|
|
17
|
+
*/
|
|
18
|
+
export const createLayerComponent = (createLayer, ref, { children, events, layerOrder, ...properties }) => {
|
|
19
|
+
const parent = useContext(LayerContext);
|
|
20
|
+
const { map } = useMap();
|
|
21
|
+
/**
|
|
22
|
+
* Create instance only on first mount
|
|
23
|
+
*/
|
|
24
|
+
const instance = useMemo(() => {
|
|
25
|
+
const layer = createLayer(properties);
|
|
26
|
+
// If the parent in a GroupLayer (or any EsriInstance that has the .add(layer) method), add it to that,
|
|
27
|
+
// otherwise, add directly to the map
|
|
28
|
+
if (parent && parent.add) {
|
|
29
|
+
parent.add(layer, layerOrder);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
map.add(layer, layerOrder);
|
|
33
|
+
}
|
|
34
|
+
return layer;
|
|
35
|
+
}, []);
|
|
36
|
+
useImperativeHandle(ref, () => instance);
|
|
37
|
+
useEsriPropertyUpdates(instance, properties);
|
|
38
|
+
useEvents(instance, events);
|
|
39
|
+
/**
|
|
40
|
+
* Remove layer on unmount
|
|
41
|
+
*
|
|
42
|
+
* TODO: Potentially fade layer out when unmounted, guide here:
|
|
43
|
+
* https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fade-a-layer-on-off-smoothly/m-p/70174
|
|
44
|
+
*/
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
return () => {
|
|
47
|
+
map.remove(instance);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
// If no children, there is no need to render a context provider
|
|
51
|
+
if (!children)
|
|
52
|
+
return null;
|
|
53
|
+
return (_jsx(LayerContext.Provider, { value: instance, children: children }));
|
|
54
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./createLayerComponent";
|
|
2
|
+
export * from "./FeatureLayer";
|
|
3
|
+
export * from "./GraphicsLayer";
|
|
4
|
+
export * from "./GroupLayer";
|
|
5
|
+
export * from "./ImageryLayer";
|
|
6
|
+
export * from "./ImageryTileLayer";
|
|
7
|
+
export * from "./KMLLayer";
|
|
8
|
+
export * from "./LayerView";
|
|
9
|
+
export * from "./WebTileLayer";
|
|
10
|
+
export * from "./WMSLayer";
|
|
11
|
+
export * from "./VectorTileLayer";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./createLayerComponent";
|
|
2
|
+
export * from "./FeatureLayer";
|
|
3
|
+
export * from "./GraphicsLayer";
|
|
4
|
+
export * from "./GroupLayer";
|
|
5
|
+
export * from "./ImageryLayer";
|
|
6
|
+
export * from "./ImageryTileLayer";
|
|
7
|
+
export * from "./KMLLayer";
|
|
8
|
+
export * from "./LayerView";
|
|
9
|
+
export * from "./WebTileLayer";
|
|
10
|
+
export * from "./WMSLayer";
|
|
11
|
+
export * from "./VectorTileLayer";
|