Chapter 10
Chapter 10
Web Apps
Python
Notebooks ArcGIS Python API,
ArcPy
Dojo
Internet
Chrome Firefox Safari Others
Explorer
Getting to Know Web GIS, fourth edition
Interacts with ArcGIS REST API
Relies on ArcGIS REST API to interact with ArcGIS Online & ArcGIS Enterprise
ArcGIS Online
ArcGIS Enterprise
HTTP responses
HTTP requests
Web browsers
Getting to Know Web GIS, fourth edition
An example
• For example, the REST URL of the second layer (earthquakes) in a feature service is
https://services2.arcgis.com/j80Jz20at6Bi0thr/arcgis/rest/services/NaturalDisasters/FeatureServer/1
Layers
Tasks Portal VectorTileLayer TileLayer MapImageLayer
IdentifyTask PortalUser
Renderers SimpleRenderer UniqueValueRenderer ClassBreaksRenderer
PrintTask PortalItem
3D symbols
PortalQueryResult
SimpleLineSymbol PolygonSymbol3D
Geoprocessor PortalQueryResult
SimpleFillSymbol
LabelSymbol3D
TextSymbol
…
…
Getting to Know Web GIS, fourth edition
Classes, objects, and constructors
• A class contains constructors that are invoked to create objects from the class blueprint
• An object is an instance of a class
• Syntax: var anObj = new aClassName(parameters);
• map
SceneView • center
• scale (at center) • heading
• zoom (at center) • tilt
• camera • position
• viewingMode • fov
• … • …
objectName.propertyName view.zoom = 6;
var zoomLevel=view.zoom
Syntax
• objectName.methodName(parameters)
• add()
Map • findLayerById()
• remove()
• …
queryTask.execute(parameters).then(
function getResults(queryResult) { },
function getErrors(err) { }
);
Getting to Know Web GIS, fourth edition
Steps using the API to build a basic map or scene app
• Adapting samples
1. Replace web map/scene IDs or layer URLs
2. Replace attributes
- Replace field names with names for the new service(s) or layer(s)
- Replace the values of the related fields
3. Replace related symbols
- To match the new feature layers and graphics
• Combining samples
- Need to load the required modules for all samples
- More work to be done based on the specific situation
• A widget is a self-contained component that you can easily incorporate into your JavaScript apps
• Examples
- BasemapGallery
- Bookmarks
- LayerList
- Legend
- Popup
- Search
- Edit
- TimeSlider
- ….
Load the module(s) in the Insatiate the widget and Add to your map/scene
require function define its properties view with a position
bottom-left bottom-right
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=widgets-legend
• Simple IDEs
- Sublime Text
- Notepad++
- …
Create several web apps for displaying a park design in 2D and 3D views
• Incorporate widgets in 2D and 3D views
• Handle mouse events to display Google Street View and pop-ups
• Use layers, renderers, and symbols for drive-through simulation in 2D and 3D views
• System requirements
- A web browser
- A JavaScript editor: e.g., Atom or Sublime Text
- ArcGIS Online: Serving services. No accounts are needed.
• The API interacts with GIS servers via ArcGIS REST API. Server responses are typically in JSON
format
• The API has core classes corresponding to 2D/3D views, maps/scenes, various layers, renderers,
symbols, portal, and various tasks
• The steps to develop a basic app using the API include: reference the API, load required modules,
create your map or scene, create the view, define the spaces (divs) to hold the view, and style the
page
• The typical steps to adapt a sample include: replace URLs (and portal item ids), replace attribute
names (and values), and replace related symbols
Submit
• The URLs of the original samples with which you started
• Your new source code