O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building Web and Mobile ArcGIS Server Applications with JavaScript - Second Edition

Book Description

Master the ArcGIS API for JavaScript to build web and mobile applications using this practical guide.

About This Book

  • Develop ArcGIS Server applications with JavaScript, both for traditional web browsers as well as the mobile platform
  • Make your maps informative with intuitive geographic layers, user interface widgets, and more
  • Integrate ArcGIS content into your custom applications and perform analytics with the ArcGIS Online

Who This Book Is For

If you are a web or mobile application developer, who wants to create GIS applications in your respective platform, this book is ideal for you. You will need Java Script programming experience to get the most out of this book. Although designed as an introductory to intermediate level book, it will also be useful for more advanced developers who are new to the topic of developing applications with ArcGIS Server.

What You Will Learn

  • To create an application with the ArcGIS API for JavaScript
  • Build and display a broad range of different geometry types to represent features on the map
  • The best way to leverage a feature layer and display related attribute data
  • The functionality of the wide range of widgets and how to use them effectively
  • Query data to gain new insights into the information it contains
  • Work with tasks to discover and locate features on the map
  • Using the geocoder and associated widgets
  • The ability of the API to provide turn by turn directions and routing capabilities
  • How to use the Geometry Engine and Geometry Service tasks for common geoprocessing operations
  • Integrate content on ArcGIS online and add it to your custom web mapping application

In Detail

The ArcGIS API for JavaScript enables you to quickly build web and mobile mapping applications that include sophisticated GIS capabilities, yet are easy and intuitive for the user.

Aimed at both new and experienced web developers, this practical guide gives you everything you need to get started with the API. After a brief introduction to HTML/CSS/JavaScript, you'll embed maps in a web page, add the tiled, dynamic, and streaming data layers that your users will interact with, and mark up the map with graphics. You will learn how to quickly incorporate a broad range of useful user interface elements and GIS functionality to your application with minimal effort using prebuilt widgets. As the book progresses, you will discover and use the task framework to query layers with spatial and attribute criteria, search for and identify features on the map, geocode addresses, perform network analysis and routing, and add custom geoprocessing operations. Along the way, we cover exciting new features such as the client-side geometry engine, learn how to integrate content from ArcGIS.com, and use your new skills to build mobile web mapping applications.

We conclude with a look at version 4 of the ArcGIS API for JavaScript (which is being developed in parallel with version 3.x) and what it means for you as a developer.

Style and approach

Readers will be taken through a series of exercises that will demonstrate how to efficiently build ArcGIS Server applications for the mobile and web.

Downloading the example code for this book. 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 code file.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Introduction to HTML, CSS, and JavaScript
    1. Basic HTML page concepts
      1. DOCTYPE
      2. Primary tags
      3. Validating HTML code
    2. JavaScript fundamentals
      1. Commenting code
      2. Variables
      3. JavaScript is case sensitive
      4. Variable data types
      5. Decision support statements
      6. Looping statements
      7. Functions
      8. Objects
    3. Basic CSS principles
      1. CSS syntax
        1. Inline styling
        2. Internal style sheet
        3. External style sheet
    4. Separating HTML, CSS, and JavaScript
    5. Summary
  3. Creating Maps and Adding Layers
    1. The ArcGIS API for JavaScript Sandbox
    2. Basic steps for creating an application with the ArcGIS API for JavaScript
      1. Creating HTML code for the page
      2. Referencing the ArcGIS API for JavaScript
      3. Loading API modules
      4. Making sure the DOM is available
      5. Creating the map
      6. Creating the page content
      7. Styling the page
      8. The entire code
    3. More about the map
    4. Working with map service layers
      1. Using the layer classes
      2. Tiled map service layers
      3. Dynamic map service layers
      4. Adding layers to the map
      5. Setting the visible layers from a map service
      6. Setting a definition expression
      7. Map navigation
        1. Map navigation widgets and toolbars
        2. Map Navigation with the mouse and keyboard
        3. Getting and setting the map extent
    5. Map events
    6. Summary
  4. Adding Graphics to the Map
    1. The four parts of a Graphic
    2. Specifying graphic geometry
    3. Symbolizing graphics
    4. Assigning attributes to graphics
    5. Changing graphic attributes in an InfoTemplate
    6. Creating the graphic
    7. Adding graphics to the GraphicsLayer
      1. Multiple GraphicsLayers
    8. Practice time
    9. Summary
  5. The Feature Layer
    1. Creating the FeatureLayer
      1. Optional constructor parameters
    2. Defining the display mode
      1. The snapshot mode
      2. The on-demand mode
      3. The selection only mode
      4. The auto mode
    3. Setting a definition expression
    4. Feature selection
    5. Rendering FeatureLayer
    6. Practice time
    7. Summary
  6. Using Widgets and Toolbars
    1. Adding toolbars to an application
      1. Steps for creating a toolbar
        1. Defining CSS styles
        2. Creating the buttons
        3. Creating an instance of the Navigation toolbar
    2. User interface widgets
      1. The BasemapGallery widget
      2. Basemap toggle widget
      3. Bookmarks widget
      4. The Print widget
      5. Layer List widget
        1. Time to practice
      6. Search widget
      7. Gauge widget
      8. Measurement widget
      9. The Popup widget
      10. Legend widget
      11. OverviewMap widget
      12. Scalebar widget
      13. Directions
      14. HistogramTimeSlider
      15. HomeButton
      16. LocateButton
      17. TimeSlider
      18. LayerSwipe
      19. The Analysis widgets
    3. Feature editing
      1. FeatureService
      2. The Editing widgets
        1. The Editor widget
        2. TemplatePicker widget
        3. AttributeInspector widget
        4. The AttachmentEditor widget
        5. The Edit toolbar
    4. Summary
  7. Performing Spatial and Attribute Queries
    1. Introducing tasks in ArcGIS Server
    2. Overview of attribute and spatial queries
    3. The Query object
      1. Setting query properties
        1. Attribute queries
        2. Spatial queries
        3. Limiting the fields returned
    4. Executing the query with QueryTask
      1. Getting the results of the query
    5. Practice time with spatial queries
    6. Summary
  8. Identifying and Finding Features
    1. Using IdentifyTask to access feature attributes
      1. Introducing IdentifyTask
      2. IdentifyParameters
      3. IdentifyTask
      4. IdentifyResult
      5. Practice time - implementing identify functionality
    2. Using FindTask to access feature attributes
      1. FindParameters
      2. FindTask
      3. FindResults
    3. Summary
  9. Turning Addresses into Points and Points into Addresses
    1. Introduction to geocoding
    2. Geocoding with a locator service in the ArcGIS API for JavaScript
      1. Input parameter object
        1. Input JSON address object
        2. Input point object
      2. Locator object
        1. The AddressCandidate object
    3. The geocoding process
    4. The reverse geocoding process
    5. Practice time with the locator service
    6. The Search widget
    7. Summary
  10. Directions and Routing
    1. Routing task
    2. Practice time with routing
    3. The Directions widget
    4. ClosestFacility Task
    5. ServiceArea task
    6. Summary
  11. Geoprocessing Tasks
    1. Models in ArcGIS Server
    2. Using the Geoprocessor task - what you need to know
    3. Understanding the services page for a geoprocessing task
      1. Input parameters
    4. The Geoprocessor task
    5. Executing the task
      1. Synchronous tasks
      2. Asynchronous tasks
    6. Practice time with geoprocessing tasks
    7. Summary
  12. Geometry Operations
    1. The Geometry Service
      1. Geometry Service operations
      2. Using the Geometry Service
    2. The Geometry Engine
    3. Practice time with the Geometry Engine
    4. Summary
  13. Integration with ArcGIS Online
    1. Adding ArcGIS Online maps to your applications by using a webmap ID
    2. Adding ArcGIS Online maps to your applications with JSON
    3. Practice time with ArcGIS Online
    4. Summary
  14. Creating Mobile Applications
    1. Compact build of the API
      1. Setting the viewport scale
      2. Practice time with the compact build
    2. Integrating the geolocation API
      1. Practice time with the geolocation API
    3. Summary
  15. Looking Ahead - Version 4 of the ArcGIS API for JavaScript
    1. Steps for creating 2D maps
      1. Accessing layers
    2. New and changed layers
      1. GraphicsLayer
      2. FeatureLayer
      3. MapImageLayer
      4. VectorTileLayer
      5. GroupLayers
      6. SceneLayers
    3. 3D mapping and symbology
      1. Scenes
      2. Creating the map
        1. Setting elevation data
        2. Setting the camera
        3. Specifying the environment
        4. Local scenes
        5. 3D symbology and rendering
    4. Summary