ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… ·...

40
ArcGIS API for JavaScript An Introduction Jo Fraley & Rene Rubalcava

Transcript of ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… ·...

Page 1: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

ArcGIS API for JavaScript

An IntroductionJo Fraley & Rene Rubalcava

Page 2: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Outline

• Setup

• First Steps

• Working with layers

• Symbols and Renderers

• Make your map interactive

• Widgets and styling

Page 3: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Presentations accessible on GitHub

• Focusing on version 4.0 for this presentation

• Concepts are similar between 3.x and 4.0

• Version 3.x UC 2015 presentation and demos are available

• https://github.com/Esri/uc-2106-JSAPI-introduction

Page 4: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Where to begin?

https://developers.arcgis.com/javascript

Page 5: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Which API version should I use?

Page 6: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Developer Setup

• Choose an IDE

• Code assist

• Helpful tools

Page 8: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

JSAPI-Resources

• Collection of resources to aid development in the JSAPI

• Some of these include:

- JSHint file

- Helps to detect errors and potential problems in code

- Typescript definition file

- Provides code assist in some IDE’s such as WebStorm and Visual Studio

- Build tools, e.g. Bower for custom builds of the API

- Callback page for popups using OAuth2 for security

Page 9: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

CSS

• Main.css

- Contains styles for all of API.

• View.css

- Better choice, if only need CSS for a basic map with default

widgets. Smaller in size.

• Custom css (sass)

- Provide widget css source

Page 10: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

First steps

• How will application be written?

• Separate files or one combined file?

• Demos shows separate HTML, CSS,

and JS files

• Reference JSAPI and any additional

references, e.g. CSS, any other

libraries in markup

Page 11: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Make a map

Page 12: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Tip

• Modules out of order

• Blank tiles -> Can’t find CSS

Page 13: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Map View

Page 14: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Add layers

• Layer types

- FeatureLayer

- MapImageLayer

- ImageryLayer

- TileLayer

- VectorTileLayer

- GroupLayer

- SceneLayer

- … and more

Page 15: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Layer coding pattern

1. Load module

2. Create layer

3. Set properties

4. Add to map (or scene)

Page 16: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Working with Properties

• All properties for each class can be set in its constructor

• No need to explicitly call Get/Set for properties

• Watch for property changes

• Use esri/core/watchUtils to aid in watching property changes

Page 17: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Demo: Add layer to sample app

Page 18: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Renderers

• Define a set of symbols to use for the layer

• Set rules on how the symbols should be used

• Basic coding pattern

Page 19: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Symbols

• Renderers make use of symbology

- Points, lines, and polygons

• Pass the symbol to the renderer

Page 20: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Autocasting

• Allows you to pass in a property without having to specifically require it in the code.

- Efficient

- Less code

- Less overhead

• Not sure if a property can use this functionality?

- Check property’s API reference for Autocast label

Page 21: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Demo: Update feature layer renderer

Page 22: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Interactive Map

• Make map interactive

- Popups

- Query

- Filter out features based on a definition expression

Page 23: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Popups

• Responsive widget

• Information about

- Clicked location

- Feature

- Search results

• Customizable

Page 24: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

FeatureLayer PopupTemplate

• View has associated popup

• Popup content is set via PopupTemplate

• FeatureLayer has popupTemplate

• Popup’s dockOptions

Page 25: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Popup: Custom Actions

Page 27: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

FeatureLayer definition expressions

• SQL where clause used to filter features on

the client

• Use with large datasets

• View automatically refreshes

Page 28: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Demo: Filtering features using a definition expression

Page 29: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Web map

• Reduce code by using a web map

- No need to write a bunch of code

• Retains all customizations with rendering, popups, filtering, etc.

- Basemap

- Layers

- Popup

- Symbology

- Extent

- Basemap

Page 30: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Demo: Add a web map to an application

Page 31: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Widgets

• BasemapToggle

• Compass

• Home

• Legend

• Search

• Popup

• Track

• Locate

• Print

• LayerList

• SmartMapping

• Specific encapsulated

functionality

Page 32: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Widget coding pattern

• Load module

• Create widget

• Set widget properties

• Add widget to UI

Page 33: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Default UI

Page 34: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Widget coding pattern

1. Load module

2. Create widget

3. Set options

4. Add widget to the UI

Page 36: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Customize widget appearance

• CSS

• SASS

Page 37: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Want more info?

• Documentation

- https://developers.arcgis.com/javascript/

• Check out Esri-related training classes and webinars

• Additional Resources

- JavaScript online training classes: free and fee-based

Page 38: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Additional sessions

• ArcGIS API for JavaScript: What's New at v4.x

• ArcGIS API for JavaScript: Advanced Topics

• ArcGIS API for JavaScript: Build 3D Web Apps

• ArcGIS API for JavaScript: Data Visualization

• ArcGIS API for JavaScript: Tips and Tricks for Dev and Debug Apps

Page 39: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some

Please take our SurveyYour feedback allows us to help maintain high standards and to help presenters

Find the session you want to review

Find your event in the Esri Events App

Scroll down to the bottom of the session

Answer survey questions and submit

Page 40: ArcGIS API for JavaScript An Introduction › library › userconf › devsummit-dc17 › p… · JSAPI-Resources •Collection of resources to aid development in the JSAPI •Some