G E T T I N G T O K N O W Web GIS G Getting to Know Web GIS is a workbook, with detailed, step-by-step exercises, that teaches E readers how to share resources online and build web GIS applications easily and quickly. It W T covers the Esri® suite of web GIS technologies, including ArcGIS® Online, Portal for ArcGIS, G E T T I N G T O K N O W T ArcGIS for Server, web app templates, Web AppBuilder for ArcGIS, ArcGIS API for JavaScriptTM, I the Collector for ArcGIS mobile app, ArcGIS Runtime SDKs for Mobile, and 3D web scenes. eN You don’t have to be a developer to build web apps. This book shows you how to build engaging G web apps with little to no programming. Unlike books that focus on individual products, this b Web book teaches web GIS technologies as a holistic platform. In each chapter, students complete T an application project. O G Data and a 60-day trial of ArcGIS for Desktop software is available on the Esri Press book resource page at esripress.esri.com/bookresources. K N Each chapter includes I • a conceptual discussion that gives readers the big picture and the underlying principles, SO • system requirements that help instructors set up the lab, W • a detailed tutorial with abundant screen captures that confirm progress along the way, • common questions and answers, • an assignment that allows readers to practice what they have learned, and • a resource section. GIS This book is the result of the author’s extensive working experience at Esri and teaching experi- ence at Harvard University Extension and other universities. It is a practical manual for class- room lab work and on-the-job training for GIS students, instructors, GIS analysts, managers, web developers, and a broad range of GIS professionals. Pinde Fu is a project lead and senior GIS application developer at Esri. His specialties include web GIS P technologies and applications in various industries. Several of his projects have won special achievement i awards. Fu is coauthor of Web GIS: Principles and Applications (Esri Press, 2011). n d e ArcGIS® for Desktop is certified for Windows® operating systems and requires Microsoft® .NET Framework to be installed. F Please read the complete list of system requirements at esri.com/arcgis102sysreq. u System requirements for this book include ArcGIS Online or Portal for ArcGIS and ArcGIS for Server. Students will need ArcGIS for Desktop, available either through a campuswide site license or from a 60-day trial link at esripress.esri.com /bookresources; a web browser, such as Google® ChromeTM, Firefox®, Microsoft® Internet Explorer®, or Safari®; Microsoft Excel® or other tools that can edit CSV files, for chapters 1, 2, 5, and 9; Microsoft IIS (Internet Information Services) or other web application servers, for chapters 6 and 8; Notepad++ or other tools that can edit JavaScript, for chapter 8; Collector for ArcGIS (on iOSTM), ADT (AndroidTM Development Toolkit), and a smart mobile device, for chapter 9; and Esri Pinde Fu CityEngine® software (one-month trial available at esri.com/software/cityengine/free-trial), for chapter 10. 141671 WLSW3M2/15jh Printed in the USA For data for this book or a link to trial software, go to the Esri Press book resource page at esripress.esri.com/bookresources. Esri Press, 380 New York Street, Redlands, California 92373-8100 Copyright © 2015 Esri All rights reserved. Printed in the United States of America 19 18 17 16 15 1 2 3 4 5 6 7 8 9 10 The information contained in this document is the exclusive property of Esri unless otherwise noted. This work is protected under United States copyright law and the copyright laws of the given countries of origin and applicable international laws, treaties, and/or conventions. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying or recording, or by any information storage or retrieval system, except as expressly permitted in writing by Esri. All requests should be sent to Attention: Contracts and Legal Services Manager, Esri, 380 New York Street, Redlands, California 92373-8100, USA. The information contained in this document is subject to change without notice. US Government Restricted/Limited Rights: Any software, documentation, and/or data delivered hereunder is subject to the terms of the License Agreement. The commercial license rights in the License Agreement strictly govern Licensee’s use, reproduction, or disclosure of the software, data, and documentation. In no event shall the US Government acquire greater than RESTRICTED/LIMITED RIGHTS. At a minimum, use, duplication, or disclosure by the US Government is subject to restrictions as set forth in FAR §52.227-14 Alternates I, II, and III (DEC 2007); FAR §52.227-19(b) (DEC 2007) and/or FAR §12.211/12.212 (Commercial Technical Data/Computer Software); and DFARS §252.227-7015 (DEC 2011) (Technical Data – Commercial Items) and/or DFARS §227.7202 (Commercial Computer Software and Commercial Computer Software Documentation), as applicable. Contractor/Manufacturer is Esri, 380 New York Street, Redlands, CA 92373-8100, USA. @esri.com, 3D Analyst, ACORN, Address Coder, ADF, AML, ArcAtlas, ArcCAD, ArcCatalog, ArcCOGO, ArcData, ArcDoc, ArcEdit, ArcEditor, ArcEurope, ArcExplorer, ArcExpress, ArcGIS, arcgis.com, ArcGlobe, ArcGrid, ArcIMS, ARC/INFO, ArcInfo, ArcInfo Librarian, ArcLessons, ArcLocation, ArcLogistics, ArcMap, ArcNetwork, ArcNews, ArcObjects, ArcOpen, ArcPad, ArcPlot, ArcPress, ArcPy, ArcReader, ArcScan, ArcScene, ArcSchool, ArcScripts, ArcSDE, ArcSdl, ArcSketch, ArcStorm, ArcSurvey, ArcTIN, ArcToolbox, ArcTools, ArcUSA, ArcUser, ArcView, ArcVoyager, ArcWatch, ArcWeb, ArcWorld, ArcXML, Atlas GIS, AtlasWare, Avenue, BAO, Business Analyst, Business Analyst Online, BusinessMAP, CityEngine, CommunityInfo, Database Integrator, DBI Kit, EDN, Esri, esri.com, Esri—Team GIS, Esri—The GIS Company, Esri—The GIS People, Esri—The GIS Software Leader, FormEdit, GeoCollector, Geographic Design System, Geography Matters, Geography Network, geographynetwork.com, Geoloqi, Geotrigger, GIS by Esri, gis.com, GISData Server, GIS Day, gisday.com, GIS for Everyone, JTX, MapIt, Maplex, MapObjects, MapStudio, ModelBuilder, MOLE, MPS—Atlas, PLTS, Rent-a-Tech, SDE, SML, Sourcebook•America, SpatiaLABS, Spatial Database Engine, StreetMap, Tapestry, the ARC/INFO logo, the ArcGIS Explorer logo, the ArcGIS logo, the ArcPad logo, the Esri globe logo, the Esri Press logo, The Geographic Advantage, The Geographic Approach, the GIS Day logo, the MapIt logo, The World’s Leading Desktop GIS, Water Writes, and Your Personal Geographic Information System are trademarks, service marks, or registered marks of Esri in the United States, the European Community, or certain other jurisdictions. CityEngine is a registered trademark of Procedural AG and is distributed under license by Esri. Other companies and products or services mentioned herein may be trademarks, service marks, or registered marks of their respective mark owners. Ask for Esri Press titles at your local bookstore or order by calling 800-447-9778, or shop online at esri.com/esripress. Outside the United States, contact your local Esri distributor or shop online at eurospanbookstore.com/esri. Esri Press titles are distributed to the trade by the following: In North America: Ingram Publisher Services Toll-free telephone: 800-648-3104 Toll-free fax: 800-838-1149 E-mail: [email protected] In the United Kingdom, Europe, Middle East and Africa, Asia, and Australia: Eurospan Group 3 Henrietta Street London WC2E 8LU United Kingdom Telephone: 44(0) 1767 604972 Fax: 44(0) 1767 601640 E-mail: [email protected] Contents Preface _________________________________________________ix Acknowledgments _______________________________________xi System requirements ____________________________________xiii Chapter 1 Start with the cloud: Build web apps using ArcGIS Online____1 1.1 Create an ArcGIS Online account __________________________ 9 1.2 Prepare your data _______________________________________ 13 1.3 Create a web map ______________________________________ 16 1.4 Create a web app using a template _______________________ 19 1.5 Configure your web app _________________________________ 24 1.6 Share your web app _____________________________________ 33 Chapter 2 More on ArcGIS Online layers, maps, and apps __________39 2.1 Map CSV data using geocoding __________________________ 43 2.2 Edit data in the map viewer _______________________________47 2.3 Change layer symbols ___________________________________ 50 2.4 Configure layer pop-up windows _________________________ 54 2.5 Add images and charts to pop-up windows ________________ 58 2.6 Add a layer by search ___________________________________ 63 2.7 Create and configure your web app _______________________ 66 Chapter 3 Map services and time animation _______________________ 77 3.1 Connect to your GIS server ______________________________ 84 3.2 Author your map document _______________________________87 3.3 Enable time on your map layers __________________________ 93 3.4 Publish your map as a service ____________________________ 96 3.5 Explore your service using Services Directory _____________ 102 3.6 Add a map service to a web map and configure time ________107 3.7 Build a time animation web app __________________________111 Chapter 4 Cached map services and comparison web apps ________ 121 4.1 Configure a data store __________________________________ 129 4.2 Author a map for tiling _________________________________ 132 4.3 Publish a tiled map service ______________________________ 135 4.4 Check the tiles and test your service _____________________ 142 4.5 Create a side-by-side comparison web app _______________ 145 4.6 Administer your web services ___________________________ 152 vi Contents Chapter 5 Feature services and volunteered geographic information __________________________________________159 5.1 Create an ArcGIS Online for Organizations publisher account______________________________________ 164 5.2 Prepare your data _______________________________________167 5.3 Publish a hosted feature service _________________________ 168 5.4 Define feature templates ________________________________172 5.5 Create a web map and define editable fields ______________ 180 5.6 Create a web app for VGI collection _______________________181 Chapter 6 Web AppBuilder for ArcGIS ___________________________193 6.1 Access Web AppBuilder ________________________________ 198 6.2 Create a basic web app _________________________________ 199 6.3 Configure additional widgets ___________________________ 207 6.4 Deploy your application ________________________________ 220 Chapter 7 Spatial analytics online and geoprocessing services _____225 7.1 Design a geoprocessing model _________________________ 233 7.2 Run the model_________________________________________ 240 7.3 Publish the results as a geoprocessing service ____________ 244 7.4 Explore your geoprocessing service in the Services Directory _____________________________________ 249 7.5 Use your GP service in Web AppBuilder for ArcGIS ________ 253 Chapter 8 Getting started with ArcGIS API for JavaScript _________263 8.1 Build your first app _____________________________________ 272 8.2 Adapt a sample ________________________________________ 273 8.3 Deploy your app to your web server ______________________281 8.4 Debug JavaScript, monitor HTTP traffic, and inspect elements __________________________________ 284 8.5 Add dijits to your web app ______________________________ 293 8.6 Select features from a feature layer ______________________ 301 Chapter 9 Mobile GIS ___________________________________________313 9.1 Prepare your web map (optional) ________________________ 319 9.2 Collect points using Collector for ArcGIS _________________ 320 9.3 Stream lines and polygons using Collector ________________ 328 9.4 Explore JavaScript API mobile samples ___________________ 334 9.5 Install the ArcGIS for Android Eclipse plug-in _____________ 336 9.6 Getting started with ArcGIS Runtime SDK for Android _____ 339 9.7 Adapt a Runtime Android SDK sample ___________________ 346 Cont ents vii Chapter 10 3D web apps _________________________________________355 10.1 Build essential skills ____________________________________ 358 10.2 Explore basic polygonal modeling _______________________ 358 10.3 Publish web scenes ____________________________________ 358 Appendix A: Image credits __________________________________________361 Appendix B: Data credits ___________________________________________ 375 Appendix C: Server data credits ____________________________________ 377 ix Preface Getting to Know Web GIS is a workbook, with detailed, step-by-step exercises, that teaches readers how to share resources online and build web GIS applications easily and quickly. It is a practical manual for classroom lab work and on-the-job training for GIS students, instructors, GIS analysts, managers, web developers, and a broad range of GIS professionals. It covers the Esri suite of web GIS technologies, including ArcGIS Online, Portal for ArcGIS, ArcGIS for Server, web app templates, Web AppBuilder for ArcGIS, ArcGIS API for JavaScript, the Collector for ArcGIS mobile app, ArcGIS Runtime SDKs for Mobile (iOS, Android, and Windows Phone), Esri CityEngine, and 3D web scenes. The sample data for this book and a 60-day trial of ArcGIS for Desktop software is available on the Esri Press book resource page at esripress.esri.com/bookresources. Web GIS is a promising field with great applicability to e-government, e-business, e-science, and daily life. The societal need for both the web and GIS has generated a strong and increasing demand for good web GIS professionals. Professors need a lab book to teach this course, and on-the-job professionals need a guide to teach themselves. This book fits the need. In writing this book, I have tried to keep these provisions in mind and make it: • Easy to apply: Web GIS is quite a technical field, but you do not have to be a developer to build web apps. This book facilitates immediate productivity. It teaches how to build engaging web apps without a single line of programming. Even the two chapters involving programming are designed to be easy to follow and do not require a strong programming background. • Current: Web GIS technologies advance rapidly. The book teaches state-of-the-art technical skills needed for building applications and managing projects. • Holistic: Unlike books that focus on individual products, this book teaches web GIS technologies as a holistic platform, from the server side to the browser, mobile, and desktop client side, as illustrated in the following figure. This book also addresses the pros and cons of the available development options and helps you make the best choices based on your requirements and resources. x Preface ArcGIS offers many ways to build web applications. The thick red lines in the figure highlight the technologies each chapter teaches. Each of the 10 chapters provides • a conceptual discussion that gives readers the big picture and the underlying principles, • system requirements that help instructors set up the lab, • a detailed tutorial with abundant screen captures that confirm progress along the way, • common questions and answers, • an assignment that allows readers to practice what they have learned, and • a resource section. The book is the result of my extensive working experience at Esri and teaching experience at Harvard University Extension, Henan University, and the University of Redlands. This course and the set of labs have been well recognized by these universities and students. Professors can use this book as the lab book for their web GIS courses, and professionals at work can use this book for on-the-job training. I welcome your feedback at [email protected] and hope this book sparks your imagination and encourages creative uses of web GIS. xi Acknowledgments I would like to thank Esri Press for inviting me to write this book and for supporting me in editing and greatly improving the language of the book, carefully testing all the exercises and helping me set up the online resources for this book, reviewing the copyright permissions, and designing the front cover and the great layout work. I am grateful for the support of my colleagues at Esri. Thanks to Mourad Larif and Bill Derrenbacher for giving me the flexibility to work on the book. Thanks to Derek Law and Geri Miller for reviewing the book and giving their outstanding suggestions. Thanks to Clint Brown, Jeremy Bartley, Urban MacGillivray, Ismael Chivite, Moxie Zhang, Jianxia Song, Michael Gould, Li Lin, Wei Zhao, Allen Carroll, Rupert Essinger, Nathan Shephard, Matthias Buehler, and Michael Lau for sharing enlightened discussions and for their support in many ways. This book was developed based on my work experience at Esri and my teaching and lecturing experience at Harvard University Extension, Henan University, and the University of Redlands. Deep thanks to Professor Michael Goodchild for his encouragement in the process of writing this book. Sincere thanks to my students for providing feedback that has helped me to improve the content and structure of this course. Thanks to Professor Yaochen Qin, Professor Yu Chen, Quntao Yang, Jingqi Lu, Yunkun Zhu, Zhenzhen Yun, Pengmin Hou, Zhidan Liu, and Dandan Zhao of Henan University for their assistance. Finally, I would like to thank my family for their love and support.