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.
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.
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.
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.
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."
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 <[email protected]>
, 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.
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.
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.
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 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 <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.