Book Image

Building Web and Mobile ArcGIS Server Applications with JavaScript

By : Eric Pimpler
Book Image

Building Web and Mobile ArcGIS Server Applications with JavaScript

By: Eric Pimpler

Overview of this book

<p>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 of developing your custom applications for ArcGIS Server since it can be used for both web and mobile application development. It’s easy to use and doesn’t require the use of a browser plugin.</p> <p>This tutorial-based guide provides you with hands-on experience in developing custom web and mobile ArcGIS Server applications with step-by-step style exercises. Along with introducing you to the HTML/CSS/JavaScript technology stack, you will learn to add intuitive geographic layers of information to your map, interactive query and display of spatial data, add user interface widgets, access geoprocessing tasks, and many more in your own web and mobile GIS applications.</p> <p>With this practical, hands-on guide, you will be able to develop fully-functional online GIS applications with ArcGIS Server using the ArcGIS API for JavaScript. After creating your own map, you will explore how to add geographic layers from a variety of sources including tiled and dynamic map services, add graphics to the map, and stream geographic features to the browser using a FeatureLayer.</p> <p>Most applications include the specific functionalities implemented by ArcGIS Server as tasks. You’ll learn how to use the various tasks provided by ArcGIS Server including spatial and attribute queries, identification of features, finding features by attribute, and more. Geocoding and geoprocessing tasks are covered in-depth to help you accomplish your task in GIS. Finally, you’ll learn just how easy it is to integrate ArcGIS.com content into your custom developed applications.</p> <p>This comprehensive guide quickly advances through probing programmatic techniques for building web and mobile GIS applications which will make application development a lot easier!</p>
Table of Contents (20 chapters)
Building Web and Mobile ArcGIS Server Applications with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

ArcGIS Server is the predominant platform used to develop GIS applications for the Web. There are a number of programming languages you can use to develop applications with ArcGIS Server, including JavaScript, Flex, and Silverlight. JavaScript has become the preferred language for developing applications on this platform, since it can be used for both web and mobile applications and doesn't require the installation of a plugin for the application to be used in a browser. Flex and Silverlight both fall short as languages for mobile development and both require the use of a plugin for the application to run in a browser.

This book will teach you how to build web-based GIS applications using the ArcGIS API for JavaScript. Using a practical, hands-on style of learning, you will learn how to develop fully functional applications with ArcGIS Server and develop a skill set that is in high demand.

You will learn how to create maps and add geographic layers from a variety of sources, including tiled and dynamic map services. In addition, you'll learn how to add graphics to the map and stream geographic features to the browser using FeatureLayer. Most applications also include specific functionalities implemented by ArcGIS Server as tasks. You'll learn how to use the various tasks provided by ArcGIS Server, including queries, identification of features, finding features by attributes, geoprocessing tasks, and more. Finally, you'll learn just how easy it is to develop mobile applications with the ArcGIS API for JavaScript.

What this book covers

Chapter 1, Introduction to HTML, CSS, and JavaScript, covers fundamental HTML, CSS, and JavaScript concepts before getting started with developing GIS applications with the ArcGIS API for JavaScript.

Chapter 2, Creating Maps and Adding Layers, teaches you how to create a map and add layers to the map. You will learn how to create an instance of the Map class, add layers of data to the map, and display this information on a web page. The Map class is the most fundamental class in the API as it provides the canvas for your data layers and any subsequent activities that occur in your application. However, your map is useless until you add layers of data. There are several types of data layers that can be added to a map, including tiled, dynamic, and feature. Readers will learn more about each of these layer types in this chapter.

Chapter 3, Adding Graphics to the Map, teaches the reader how to display temporary points, lines, and polygons in GraphicsLayer on the map. GraphicsLayer is a separate layer that always resides on top of other layers and stores all the graphics associated with the map.

Chapter 4, The Feature Layer, offers additional capabilities, apart from inheriting from GraphicsLayer, such as the ability to perform queries and selections. Feature layers are also used for online editing of features. Feature layers differ from tiled and dynamic map service layers, because feature layers bring geometry information to the client computer to be drawn and stored by the web browser. Feature layers potentially cut down on round trips to the server. A client can request the features it needs, and perform selections and queries on those features without having to request more information from the server.

Chapter 5, Using Widgets and Toolbars, covers out-of-the-box widgets that you can drop into your application for enhanced productivity. The BasemapGallery, Bookmarks, Print, Geocoding, Legend, Measurement, Scalebar, Gauge, and Overview map widgets are included. In addition, the ArcGIS API for JavaScript also includes helper classes for adding various toolbars to your applications, including navigation and drawing toolbars.

Chapter 6, Performing Spatial and Attribute Queries, covers the ArcGIS Server Query Task, which allows you to perform attribute and spatial queries against data layers in a map service that have been exposed. You can also combine these query types to perform a combination attribute and spatial query.

Chapter 7, Identifying and Finding Features, covers two common operations found in any GIS application. These operations require that the user click a feature on the map in the case of identification, or perform a query in the case of finding features. In either case, information about particular features is returned. In this chapter, the reader will learn how to use the IdentifyTask and FindTask objects to obtain information about features.

Chapter 8, Turning Addresses into Points and Points into Addresses, covers the use of the Locator task to perform geocoding and reverse geocoding. Geocoding is the process of assigning a coordinate to an address, while reverse geocoding assigns an address to a coordinate.

Chapter 9, Network Analyst Tasks, allows you to perform analyses on street networks, such as finding the best route from one address to another, finding the closest school, identifying a service area around a location, or responding to a set of orders with a fleet of service vehicles.

Chapter 10, Geoprocessing Tasks, allows you to execute custom models built in ArcGIS Desktop using ModelBuilder. Models are run in an automated fashion from either a desktop environment or via a centralized server accessed through a web application. Any tool found in ArcToolbox, whether that be a tool for your ArcGIS license level or a custom tool that you've built, can be used in a model and chained together with other tools. Once constructed, these models can be run on a centralized server and accessed via web applications. In this chapter, we will examine how you can access these geoprocessing tasks through the ArcGIS API for JavaScript.

Chapter 11, Integration with ArcGIS Online, details how you can use the ArcGIS API for JavaScript to access the data and maps created with ArcGIS.com. The website ArcGIS.com is for working with maps and other types of geographic information. On this site, you will find applications for building and sharing maps. You will also find useful basemaps, data, applications, and tools that you can view and use, plus communities you can join. For application developers, the really exciting news is that you can integrate ArcGIS.com content into your custom developed applications using the ArcGIS API for JavaScript. In this chapter, you will explore how ArcGIS.com maps can be added to your applications.

Chapter 12, Creating Mobile Applications, details how you can build mobile GIS applications using the ArcGIS API for JavaScript. ArcGIS Server support is currently provided for iOS, Android, and BlackBerry operating systems. The API is integrated with dojox/mobile. In this chapter, you'll learn about the compact build of the API that makes web mapping applications possible through web-kit browsers as well as the built-in gesture support.

Appendix, Application Design with ArcGIS Templates and Dojo, covers one of the most difficult tasks for many web developers which is designing and creating the user interface. The ArcGIS API for JavaScript and Dojo greatly simplifies this task. Dojo's layout dijits provide a simple, efficient way to create application layouts, and Esri has provided a number of sample application layouts and templates that you can use to get up and running quickly. In this appendix, the reader will learn techniques to design an application quickly.

What you need for this book

To complete the exercises in this book, you will need access to a web browser—preferably Google Chrome or Firefox. Each chapter contains exercises designed to supplement the material presented. Exercises will be completed using the ArcGIS API for JavaScript Sandbox to write and test your code. The Sandbox can be found at http://developers.arcgis.com/en/javascript/sandbox/sandbox.html. The exercises will access publicly available instances of ArcGIS Server, so it will not be necessary for you to install ArcGIS Server.

Who this book is for

If you are an application developer who wants to develop web and mobile GIS applications using ArcGIS Server and the API for JavaScript, this book is ideal for you. It is primarily oriented towards beginners and intermediate-level GIS developers or application developers who are more traditional and may not have developed GIS applications in the past, but are now tasked with implementing solutions on this platform. No prior experience with ArcGIS Server, JavaScript, HTML, or CSS is expected, but it is certainly helpful.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Add the onorientationchange() event to the <body> tag."

A block of code is set as follows:

routeParams = new RouteParameters();
routeParams.stops = new FeatureSet();
routeParams.outSpatialReference = {wkid:4326};
routeParams.stops.features.push(stop1);
routeParams.stops.features.push(stop2);

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

function computeServiceArea(evt) {
  map.graphics.clear();
  var pointSymbol = new SimpleMarkerSymbol();
  pointSymbol.setOutline = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1);
  pointSymbol.setSize(14);
  pointSymbol.setColor(new Color([0, 255, 0, 0.25]));       
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Run button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.