Table Of ContentRene Rubalcava
M A N N I N G
ArcGIS Web Development
ii
ArcGIS
Web Development
RENE RUBALCAVA
MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 261
Shelter Island, NY 11964
Email: orders@manning.com
©2015 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15 percent recycled and processed without elemental chlorine.
Manning Publications Co. Development editor: Susan Conant
20 Baldwin Road Technical development editor: Florian Lengyel
PO Box 261 Technical proofreader: Brian Arnold
Shelter Island, NY 11964 Copyeditors: Lianna Wlasiuk,
Katie Petito
Proofreader: Melody Dolab
Typesetter: Marija Tudor
Cover designer: Marija Tudor
ISBN: 9781617291616
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 19 18 17 16 15 14
brief contents
PART 1 ARCGIS JAVASCRIPT FOUNDATION .............................. 1
1 ■ GIS as a tool 3
2 ■ Introducing core API concepts 17
3 ■ Working with the REST API 45
PART 2 SAMPLE USE CASE ..................................................... 65
4 ■ Building an application 67
5 ■ Developing a custom data-collection application 101
6 ■ Building a desktop browser application 135
7 ■ Advanced techniques 175
v
vi
contents
preface xi
acknowledgments xiii
about this book xiv
PART 1 ARCGIS JAVASCRIPT FOUNDATION .................. 1
1 GIS as a tool 3
1.1 GIS: here, there, everywhere 4
The GIS tools landscape 4 ■ Introducing the ArcGIS
platform 6 ■ Why care about spatial applications? 7
Trends in the GIS industry 8
1.2 Understanding the GIS bits 9
The what and the where of GIS data 10 ■ Serving GIS data:
ArcGIS Server and the REST API 11 ■ Choosing an ArcGIS
web API 12
1.3 Things to know 13
JavaScript, Dojo Toolkit, and Dijit 13 ■ Introducing a tad of
GIS 14 ■ Interacting with the ArcGIS REST API 15
1.4 Summary 15
vii
viii CONTENTS
2 Introducing core API concepts 17
2.1 From data to map 18
Parts of a basic map 19 ■ Specifying common map options 22
2.2 Understanding layers and accessing data 24
Layer types for raster-based data 25 ■ Layer types for vector-
based data 27 ■ Getting to know the GraphicsLayer 28
Creating graphics with the QueryTask 30
2.3 Working with the FeatureLayer 35
Advantages of a FeatureLayer 36 ■ Creating a
FeatureLayer 38 ■ Optimizing application performance 39
Selecting items in the FeatureLayer 42
2.4 Summary 44
3 Working with the REST API 45
3.1 Introducing the ArcGIS Server REST API 47
Exploring how the API works 47 ■ Interacting with ArcGIS
Server pages 49
3.2 Building your own widget 52
Building the legend root menu 52 ■ Retrieving legend
details 53 ■ Displaying details in the custom legend
widget 54 ■ Working with multiple symbols in a feature 55
3.3 Working with the geometry service 56
Buffer your heart out 56 ■ Buffer and select 59
Buffer and intersect 61
3.4 Summary 64
PART 2 SAMPLE USE CASE .......................................... 65
4 Building an application 67
4.1 What are you going to build? 68
Using a tablet or phone 69 ■ Collecting points 69
Performing disconnected editing 69
4.2 Working with ArcGIS Online 70
ArcGIS Online vs. ArcGIS Server 70 ■ Setting up an ArcGIS
Online account 71 ■ Defining a feature service 72
Accessing your ArcGIS Online feature service 77
CONTENTS ix
4.3 Building a real-world application 77
Setting up Dojo and organizing modules 78 ■ Tying the
application together 83
4.4 Adding layers and using the renderer 87
Adding layers with a module 87 ■ Using the renderer 90
Applying the renderer 91 ■ Setting up the editing tools 92
Assigning an action to a button 95
4.5 Summary 99
5 Developing a custom data-collection application 101
5.1 Performing default web map editing 102
Finding feature service information 104 ■ Adding your feature
service to the map 105 ■ Adding the TemplatePicker and
default Editor widgets 109
5.2 Building a custom edit tool 113
Working with the custom edit functionality 114 ■ Refining the
custom edit tool 120
5.3 Enabling disconnected editing 125
Local storage 126 ■ Caveats 134 ■ Other storage
options 134
5.4 Summary 134
6 Building a desktop browser application 135
6.1 The project ahead 136
Goals of the RequestViewer 136 ■ Freedom of the desktop
browser 136
6.2 Setting up and configuring the RequestViewer 138
Creating index.html 138 ■ Configuring run.js 138
Starting the RequestViewer 139 ■ Defining map services 140
Setting up the application controller 140
6.3 Setting up authentication with OAuth 2.0 142
Using your developer account to create an application 142
Updating main.js 145 ■ Saving credentials 146
6.4 Building the user interface 152
Working with the Measurement widget 152 ■ Working with the
BasemapToggle widget 157