This project calculates a watershed based on a point selected on a map.
This utilizes ArcGIS API for JavaScript 4.10 together with the Hydrology geoprocessing services at hydro.arcgis.com.
Computing watersheds consumes a small amount of ArcGIS Online credits based on number of features. See spatial analysis pricing. Because of this, authentication is required to use this app.
The app runs in a web browser. If run with the proxy service enabled it can be run from anywhere. If not using the proxy, then a ArcGIS login is required and that will require running this page from a web server because of the authentication process.
This app also demonstrates authentication and proxy services. When useProxy
is true,
the app expects to have a proxy URL setup to the watershed service. See Access services with OAuth 2 for a tutorial and additional information about this type of authentication and setting up a proxy with ArcGIS.
When useProxy
is false, the app creates a UI to log in an ArcGIS user with ArcGIS Online. To run this, it requires a bit of setup:
- You must run this from a web server (not file:// or codepen.)
- You must have an ArcGIS Developer account. If you do not, sign up for free.
- You must have a Client ID created from an app. Create a new app at or use an existing one.
- In the app authentication definition, be sure to whitelist your web server referrer URL (e.g. http://localhost/your-app/index.html or whatever you use.)
- To test the proxy version you need to create a Hydrology proxy at https://developers.arcgis.com/applications/{your-app-id}/services then select the Services tab to define proxy services.
- You must whitelist your web server referrer URL (e.g. http://localhost/your-app/index.html or whatever you use.)
- Copy the proxy URL and paste it into
index.js
athydrologyWatershedProxy
. Remove the/submitJob
URL path component from the generated proxy URL. - In this apps'
index.js
file setuseProxy
totrue
.
- To test the non-proxy version:
- In this apps'
index.js
file setuseProxy
tofalse
. - When the page loads, click sign in and sign in with your ArcGIS for Developer's account.
- In this apps'
Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.
Copyright 2017-2019 Esri
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A copy of the license is available in the repository's LICENSE file.