Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ The main example here includes the [2D Measurement widget](https://developers.ar

![Screenshot](https://github.com/gavinr/js-api-widget-wrapper-experience-builder/raw/master/screencast.gif)

### Icon Widget
([builder interface](https://github.com/gavinr/js-api-widget-wrapper-experience-builder/raw/master/builder-screencast.mp4))

## Quick Start - Download

1. [Download](https://developers.arcgis.com/downloads/apis-and-sdks?product=arcgis-experience-builder) and unzip [Experience Builder Developer Edition](https://developers.arcgis.com/experience-builder/).
2. Download the latest [release](https://github.com/gavinr/js-api-widget-wrapper-experience-builder/releases) from this repository.
3. Unzip the downloaded files, and copy the `js-api-widget-wrapper` folder into the `client\your-extensions\widgets\js-api-widget-wrapper` folder of the extracted Experience Builder files.

## Quick Start - Git

1. [Download](https://developers.arcgis.com/downloads/apis-and-sdks?product=arcgis-experience-builder) and unzip [Experience Builder Developer Edition](https://developers.arcgis.com/experience-builder/).
2. Open a new terminal window and browse to the `client` folder.
3. `git clone https://github.com/gavinr/js-api-widget-wrapper-experience-builder`
4. `npm ci`
5. `npm start`
6. Start Experience Builder server per the instructions (in a separate terminal, `cd server`, `npm ci`, `npm start`)

## Development

1. Open the `client` folder as a project in VS Code (or similar code editor).
1. Make sure *both* scripts are running (in the `server` folder and `client`) folder).
1. Every time you make a change to your widget, it will be re-built with webpack automatically.

## Icon Widget

If you want to include a widget that is primarily placed as an icon over the map (using `view.ui.add()`), like the [Compass widget](https://developers.arcgis.com/javascript/latest/sample-code/widgets-compass-2d/index.html), an example is shown in the [compass branch here](https://github.com/gavinr/js-api-widget-wrapper-experience-builder/tree/compass) ([download zip](https://github.com/gavinr/js-api-widget-wrapper-experience-builder/archive/compass.zip)). This will be a less-common use case for custom widgets, because the out-of-the-box Experience Builder Map Widget allows you to easily enable/disable these types of widgets in the widget settings.
Binary file added builder-screencast.mp4
Binary file not shown.
3 changes: 0 additions & 3 deletions config.json

This file was deleted.

22 changes: 4 additions & 18 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
{
"name": "js-api-widget-wrapper",
"label": "JS API Wrapper",
"type": "widget",
"version": "1.0.0",
"dependency": "jimu-arcgis",
"exbVersion": "1.0.0-beta.2",
"author": "Gavin Rehkemper, Esri",
"description": "Example of an Experience Builder widget that can wrap any ArcGIS API for JavaScript widget.",
"copyright": "",
"license": "http://www.apache.org/licenses/LICENSE-2.0",
"properties": {},
"supportedLocales": [
"en"
],
"defaultSize": {
"width": 800,
"height": 500
}
"name": "js-api-widget-wrapper-experience-builder",
"type": "exb-web-extension-repo",
"description": "This is a extension repository that contains the js-api-widget-wrapper widget.",
"license": "http://www.apache.org/licenses/LICENSE-2.0"
}
Binary file modified screencast.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions src/config.ts

This file was deleted.

34 changes: 0 additions & 34 deletions tests/widget.test.tsx

This file was deleted.

1 change: 1 addition & 0 deletions widgets/js-api-widget-wrapper/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
File renamed without changes
19 changes: 19 additions & 0 deletions widgets/js-api-widget-wrapper/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "js-api-widget-wrapper",
"label": "JS API Wrapper",
"type": "widget",
"version": "1.0.0",
"dependency": "jimu-arcgis",
"exbVersion": "1.0.0",
"author": "Gavin Rehkemper, Esri",
"description": "Example of an Experience Builder widget that can wrap any ArcGIS API for JavaScript widget.",
"license": "http://www.apache.org/licenses/LICENSE-2.0",
"properties": {},
"supportedLocales": [
"en"
],
"defaultSize": {
"width": 800,
"height": 500
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,23 @@ export default class Widget extends BaseWidget<AllWidgetProps<IMConfig>, any> {
jimuMapView: jmv
});

// since the widget replaces the container, we must create a new DOM node
// so when we destory we will not remove the "ref" DOM node
const container = document.createElement("div");
this.myRef.current.appendChild(container);

const distanceMeasurement2D = new DistanceMeasurement2D({
view: jmv.view,
container: container
});
// Save reference to the "Current widget" in State so we can destroy later if necessary.
this.setState({
currentWidget: distanceMeasurement2D
});
if(this.myRef.current) {
// since the widget replaces the container, we must create a new DOM node
// so when we destroy we will not remove the "ref" DOM node
const container = document.createElement("div");
this.myRef.current.appendChild(container);

const distanceMeasurement2D = new DistanceMeasurement2D({
view: jmv.view,
container: container
});
// Save reference to the "Current widget" in State so we can destroy later if necessary.
this.setState({
currentWidget: distanceMeasurement2D
});
} else {
console.error('could not find this.myRef.current');
}
}
};

Expand Down Expand Up @@ -85,8 +89,8 @@ export default class Widget extends BaseWidget<AllWidgetProps<IMConfig>, any> {
className="widget-js-api-widget-wrapper jimu-widget"
style={{ overflow: "auto" }}
>
{jmc}
<div className="here" ref={this.myRef}></div>
{jmc}
</div>
);
}
Expand Down