-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
237761a
commit cbe887d
Showing
58 changed files
with
512 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,48 @@ | ||
# ArcGIS REST JS Samples | ||
|
||
This repository contains a variety of samples of different ways to use [ArcGIS REST JS](https://github.com/Esri/arcgis-rest-js). Please see the [samples folder](samples/) for the entire list. Each sample has a README file to explain how to run the sample. | ||
|
||
## Local ArcGIS REST JS | ||
|
||
If you'd like to use a local version of ArcGIS REST JS while running one of the samples, follow these steps. | ||
|
||
### Local ArcGIS REST JS (NPM) | ||
|
||
For samples that use NPM to install ArcGIS REST JS as a dependency, follow these steps. | ||
|
||
1. In the ArcGIS REST JS repo run any relevant build commands for the packages with which you are working. | ||
1. In the terminal, `cd` onto the package you want to link. E.g. `cd packages/arcgis-rest-request`. | ||
1. Run `npm link`. | ||
1. In this repo, `cd` into the demo you want to run and run the `npm link` command for the package you want to link. `npm link @esri/arcgis-rest-request` | ||
|
||
Remember that you must run `npm run build` in the ArcGIS REST JS repository after making changes to see those changes when running the sample. | ||
|
||
To remove the link and use the package from NPM instead of the local one, run `npm install` in the sample folder again. | ||
|
||
### Local ArcGIS REST JS (Browser) | ||
|
||
For samples that use a `<script>` tag to reference ArcGIS REST JS in the browser, follow these steps. | ||
|
||
1. In the ArcGIS REST JS directory, run these commands. This will run a local server hosting ArcGIS REST JS. | ||
|
||
```bash | ||
npm install | ||
npm run build | ||
node .\scripts\run-demo-server.js | ||
``` | ||
|
||
2. In this sample's directory, in the HTML file code, change the `<script>` tag(s) from `https://unpkg.com` to `https://localhost:8080` (or whatever port is used in step 1). For example, change this: | ||
|
||
```html | ||
<script src="https://unpkg.com/@esri/arcgis-rest-feature-service/dist/bundled/feature-service.umd.js"></script> | ||
``` | ||
|
||
... to this: | ||
|
||
```html | ||
<script src="https://localhost:8080/@esri/arcgis-rest-feature-service/dist/bundled/feature-service.umd.js"></script> | ||
``` | ||
|
||
## Sample Repository Maintenance | ||
|
||
In order to not need to constantly update the packages, we are not including `package-lock.json` files within samples the use NPM to install dependencies. See [.gitignore](.gitignore). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# Running this demo | ||
# Attachments Browser | ||
|
||
1. Make sure you run `npm run build` in the root folder to setup the dependencies | ||
1. `npm start` | ||
1. Visit http://localhost:8080 | ||
## Running this sample | ||
|
||
**Note:** The server starts with a special configuration to serve URLs starting with `@esri/arcgis-rest-*` from their respective packages. In your application you will need to change these URLs to point to their respective locations. | ||
For this sample, you do not need to install any dependencies - it uses ArcGIS REST JS from the Unpkg CDN. To run this sample, you just need to host the `index.html` file. There are a variety of ways to do that; one simple way is to use the [serve](https://www.npmjs.com/package/serve) package: | ||
|
||
```bash | ||
npx serve | ||
``` | ||
|
||
### Local ArcGIS REST JS | ||
|
||
If you'd like to use a local version of ArcGIS REST JS, follow the [steps in the parent README](../README.md#local-arcgis-rest-js-browser), updating the script tags in these files as necessary: | ||
|
||
- `index.html` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
# Native JavaScript Modules in Node.js | ||
|
||
1. Run `npm run build` in the root directory | ||
1. Run `npm start` to make a require and log output. | ||
## Running this sample | ||
|
||
1. Run `npm install` to install the dependencies. | ||
2. Run `npm start` to make a require and log output. | ||
|
||
### Local ArcGIS REST JS | ||
|
||
If you'd like to use a local version of ArcGIS REST JS, follow the [steps in the parent README](../README.md#local-arcgis-rest-js-npm), referencing these packages that this sample uses as necessary: | ||
|
||
- `arcgis-rest-request` | ||
- `arcgis-rest-feature-service` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# ArcGIS REST JS + Native Browser Modules | ||
|
||
1. Run `npm run build` in the root directory | ||
1. Run `npm start` to spin up the development server. | ||
1. Visit [http://localhost:8080](http://localhost:8080). | ||
## Running this sample | ||
|
||
**Note:** The server starts with a special configuration to serve URLs starting with `@esri/arcgis-rest-*` from their respective packages. In your application you will need to change these URLs to point to their respective locations. | ||
For this sample, you do not need to install any dependencies - it uses ArcGIS REST JS from the Unpkg CDN. To run this sample, you just need to host the `index.html` file. There are a variety of ways to do that; one simple way is to use the [serve](https://www.npmjs.com/package/serve) package: | ||
|
||
```bash | ||
npx serve | ||
``` | ||
|
||
### Local ArcGIS REST JS | ||
|
||
If you'd like to use a local version of ArcGIS REST JS, follow the [steps in the parent README](../README.md#local-arcgis-rest-js-browser), updating the script tags in these files as necessary: | ||
|
||
- `index.html` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>ArcGIS REST JS Browser w/ Modules</title> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
|
||
</head> | ||
|
||
<body> | ||
<!-- Load the ES Modules Polyfill so we can use importmap in FF and Safari --> | ||
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script> | ||
|
||
<!-- Map package imports to URLS starting with @esri/... which will get served from the local build of the modules --> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"@esri/arcgis-rest-request": "/@esri/arcgis-rest-request/dist/bundled/request.esm.js", | ||
"@esri/arcgis-rest-portal": "/@esri/arcgis-rest-portal/dist/bundled/portal.esm.js" | ||
} | ||
} | ||
</script> | ||
|
||
<script type="module"> | ||
import { searchItems } from "@esri/arcgis-rest-portal"; | ||
|
||
let element = document.createElement("pre"); | ||
document.body.appendChild(element); | ||
|
||
searchItems("water").then((response) => { | ||
element.textContent = JSON.stringify(response, null, 2); // false | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>ArcGIS REST JS Browser w/ Modules</title> | ||
<link | ||
rel="stylesheet" | ||
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" | ||
crossorigin="anonymous" | ||
/> | ||
</head> | ||
|
||
<body> | ||
<!-- Load the ES Modules Polyfill so we can use importmap in FF and Safari --> | ||
<script | ||
async | ||
src="https://unpkg.com/[email protected]/dist/es-module-shims.js" | ||
></script> | ||
|
||
<!-- Map package imports to URLS starting with @esri/... which will get served from the local build of the modules --> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"@esri/arcgis-rest-request": "https://unpkg.com/@esri/arcgis-rest-request/dist/bundled/request.esm.js", | ||
"@esri/arcgis-rest-portal": "https://unpkg.com/@esri/arcgis-rest-portal/dist/bundled/portal.esm.js" | ||
} | ||
} | ||
</script> | ||
|
||
<script type="module"> | ||
import { searchItems } from "@esri/arcgis-rest-portal"; | ||
|
||
let element = document.createElement("pre"); | ||
document.body.appendChild(element); | ||
|
||
searchItems("water").then((response) => { | ||
element.textContent = JSON.stringify(response, null, 2); // false | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
# ArcGIS REST JS + Deno | ||
|
||
ArcGIS REST JS is fully compatible with Deno. You can import the packages from the [esm.run CDN](https://www.jsdelivr.com/esm) for the easiest use. This demo shows importing from a local install with an import map. | ||
## Running this sample | ||
|
||
You can run this demo with: | ||
ArcGIS REST JS is fully compatible with Deno. You can run this demo with: | ||
|
||
``` | ||
deno run --allow-net --import-map ./import_map.json index.js | ||
deno run --allow-net --allow-import --import-map ./import_map.json index.js | ||
``` | ||
|
||
### Local ArcGIS REST JS | ||
|
||
If you'd like to use a local version of ArcGIS REST JS, follow these steps. | ||
|
||
1. In the ArcGIS REST JS directory, run these commands. This will run a local server hosting ArcGIS REST JS. | ||
|
||
```bash | ||
npm install | ||
npm run build | ||
node .\scripts\run-demo-server.js | ||
``` | ||
|
||
2. In this sample's directory, update `import_map.json` with relative paths to the files on your computer. For example replace this: | ||
|
||
```json | ||
"https://esm.run/@esri/arcgis-rest-form-data/browser-ponyfill.mjs" | ||
``` | ||
|
||
... with this: | ||
|
||
```json | ||
"../../path/to/arcgis-rest-js/packages/arcgis-rest-form-data/browser-ponyfill.mjs" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"imports": { | ||
"@esri/arcgis-rest-form-data": "../../packages/arcgis-rest-form-data/browser-ponyfill.mjs", | ||
"@esri/arcgis-rest-fetch": "../../packages/arcgis-rest-fetch/browser-ponyfill.mjs", | ||
"@esri/arcgis-rest-request": "../../packages/arcgis-rest-request/dist/esm/index.js", | ||
"@esri/arcgis-rest-portal": "../../packages/arcgis-rest-portal/dist/esm/index.js" | ||
} | ||
} | ||
{ | ||
"imports": { | ||
"@esri/arcgis-rest-form-data": "https://esm.run/@esri/arcgis-rest-form-data/browser-ponyfill.mjs", | ||
"@esri/arcgis-rest-fetch": "https://esm.run/@esri/arcgis-rest-fetch/browser-ponyfill.mjs", | ||
"@esri/arcgis-rest-request": "https://esm.run/@esri/arcgis-rest-request/dist/esm/index.js", | ||
"@esri/arcgis-rest-portal": "https://esm.run/@esri/arcgis-rest-portal/dist/esm/index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.