Table Of ContentBuilding Web and Mobile
ArcGIS Server Applications
with JavaScript
Master the ArcGIS API for JavaScript, and build
exciting, custom web and mobile GIS applications
with the ArcGIS Server
Eric Pimpler
BIRMINGHAM - MUMBAI
Building Web and Mobile ArcGIS Server Applications
with JavaScript
Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2014
Production Reference: 1120214
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-796-5
www.packtpub.com
Cover Image by Whitney Pimpler (wpimpler@gmail.com)
Credits
Author Project Coordinator
Eric Pimpler Joel Goveya
Reviewers Proofreaders
Pouria Amirian Simran Bhogal
Ken Doman Ameesha Green
Joseph Saltenberger
Indexers
Mehreen Deshmukh
Acquisition Editor
Vinay Argekar Tejal Soni
Content Development Editor Graphics
Susmita Panda Sabat Sheetal Aute
Ronak Dhruv
Technical Editors Disha Haria
Sharvari H. Baet
Yuvraj Mannari
Pragnesh Bilimoria
Abhinash Sahu
Aparna Chand
Pooja Nair
Production Coordinator
Nikhil Potdukhe Melwyn D'sa
Copy Editors Cover Work
Kirti Pai Melwyn D'sa
Stuti Srivastava
About the Author
Eric Pimpler is the founder and owner of GeoSpatial Training Services
(geospatialtraining.com) and has over 20 years of experience in implementing
and teaching GIS solutions using Esri, Google Earth/Maps, and open source
technology. Currently, he focuses on ArcGIS scripting with Python and the
development of custom ArcGIS Server web and mobile applications using
JavaScript. He is the author of Programming ArcGIS 10.1 with Python Cookbook.
Eric has a bachelor's degree in Geography from Texas A&M University and
a master's degree in Applied Geography with a concentration in GIS from Texas
State University.
About the Reviewers
Pouria Amirian is a GIS/Computer Science lecturer, researcher, and developer
working with the National University of Ireland, Maynooth. In addition to his
collaboration with the University of Ireland, he has several scientific and academic
collaborations with world class universities in Germany, France, and the UK. He is the
author of the best-selling book on ArcGIS development, Beginning ArcGIS for Desktop
Development using .NET, published by Wiley in 2013. He has extensive experience in
the design and development of various kinds of small-scale to enterprise-distributed,
service-oriented (geospatial) information systems. Dr. Amirian is currently interested
in cutting-edge research and development projects on (geospatial) Big Data and
NoSQL databases and has recently been a technical editor of several books on the
mentioned topics. He can be contacted at pouriaamirian.arcobjects@gmail.com.
I would like to thank my friend, Dr. Majid Farahani, for his support,
understanding, and encouragement during my career. My thanks
also goes to the author and the technical review team for making this
book a fun project.
Ken Doman has worked with computers for most of his life and still likes to keep
himself occupied with them in his free time. He graduated with a bachelor's degree
in Biology from Rice University. From there, he moved from one field to another,
until he was asked to launch a GIS department for his hometown in Jacksonville,
Texas. He started with a shoebox full of notebook paper for an address database.
Before long, he published the first online map of his community. He's been hooked
on publishing web maps ever since.
Ken currently works as a GIS web developer at Bruce Harris and Associates, a private
company that provides GIS services and products for municipalities across the
United States. There, he works on an array of technologies, helping county and city
governments make their data available on web browsers.
This is the first book Ken has worked on, but he has high hopes that it won't be
his last.
I would first like to thank my wife, Luann, for her love and support.
Her love for words inspired me to take this responsibility seriously.
I'd also like to thank God, without whom nothing is possible. I
would also like to thank Bruce Harris and Associates, the City of
Plantation, Florida, and the City of Jacksonville, Texas, for giving me
the opportunity to learn more about GIS, which helped me grow in
my career.
Joseph Saltenberger works as a data analyst at a GIS software company that
specializes in spatial decision support systems for fire and EMS departments.
He graduated from the Humboldt State University with a B.S. in Natural Resources
(GIS and Remote Sensing emphasis), and the San Diego State University with an
M.S. in Geography (GIScience emphasis). His academic and professional career has
focused on using GIS for data management and analysis, and for developing custom
GIS applications.
www.PacktPub.com
Support files, eBooks, discount offers
and more
You might want to visit www.PacktPub.com for support files and downloads related to
your book.
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and
as a print book customer, you are entitled to a discount on the eBook copy. Get in touch
with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print and bookmark content
• On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface 1
Chapter 1: Introduction to HTML, CSS, and JavaScript 7
Basic HTML page concepts 7
The HTML DOCTYPE declaration 9
Primary tags 9
Validating HTML code 10
JavaScript fundamentals 12
Commenting in code 13
Variables 14
JavaScript and case sensitivity 15
Variable datatypes 15
Decision-supporting statements 17
Looping statements 17
Functions 18
Objects 19
Basic CSS principles 20
CSS syntax 22
Inline styling 25
Internal stylesheets 25
External stylesheets 25
Separating HTML, CSS, and JavaScript 26
Summary 28
Chapter 2: Creating Maps and Adding Layers 29
Introduction 30
The ArcGIS API for JavaScript Sandbox 30
Basic steps for creating an application with the ArcGIS API
for JavaScript 31
Creating HTML code for a web page 32
Description:ArcGIS Server is the leading software for developing both web and mobile GIS applications. There are a number of programming languages that you can use to develop applications with ArcGIS Server including javascript, Flex, and Silverlight. However, the ArcGIS API for javascript is the preferred way