Using JavaScript Bookmarklets to Inspect ArcGIS Server services

By: Ken Doman

ESRI Developer Summit - 2016

http://slides.com/raykendo/esri_rest_diagnostics/

Good

  • Organizes services
  • Clear heirarchy
  • Multiple formats (HTML, JSON, etc.)
  • Easy to navigate
  • Clean HTML forms and content

Not so good

  • Narrow focus
  • Must navigate to each service and layer to collect / catalog information
  • No search
  • Minimal assistance on page

ArcGIS Server REST Services

ESRI REST Diagnostics

http://raykendo.github.io/ESRI_REST_Diagnostics/

Source:   https://github.com/raykendo/ESRI_REST_Diagnostics

  • JavaScript bookmarklet applications
  • Work directly on REST Service HTML page
  • Collect and data on ArcGIS REST services
    • Requests data from REST JSON or page links
    • Presents data in a readable format
  • Assists with REST Service Useability

Why use Bookmarklets?

  • Support in all major desktop browsers
  • Easy to install (just drag to bookmark bar)
  • Self-contained applications
    • Almost no third party libraries
    • ArcGIS JavaScript API is used to draw maps
  • Can run behind firewall
  • Works with user permissions in browser
  • Spatial Reference Comparison
  • Map Service Data Extractor
  • Map Viewer *
  • Feature Counter
  • Layer Data Extractor
  • Tile Service Tester
  • Map Viewer *
  • Field Value Testers

  • Domain Data Counter
  • Select By Attributes
  • REST Search
  • Print Task Made Easy
  • Geometry Helper *

REST Diagnostic Tools

* Uses ArcGIS JavaScript API

Miscellaneous

Map Layer Level

Folder Level

Map Service Level

Spatial Reference
 Comparison Tool

Spatial Reference Comparison Tool

  • Displays spatial references of each visible map service
  • Color codes services by spatial reference
  • Provides links to well known ids (spatialreference.org)
  • Also lists services as dynamic or tiled

Map Service and Layer Data Extractors

Map Service and Layer Data Extractors

  • Loops through links to map services or service layers
  • Tests values of interest from JSON data
  • Presents data on the HTML page

Feature Counter

Feature Counter

  • Loops through each layer in a map service
  • Gets ObjectID and shape field
  • Counts number of features where 'not ObjectID is null'
    • Query for count not previously available until version 10.01
  • Counts number of features where 'not Shape is null'
  • Displays the counts on the page.

Field Value Testers and
 Domain Counter

Field Value Testers

  • Collects Field data from REST
  • Collects list of fields from HTML
  • Queries count only where 'not <field> is null'
  • Writes count under the field name in the HTML
    • Will warn if count is 0 with !!!
  • Writes the return time for the query in milliseconds

Domain Data Tester

  • Finds fields with Domains through REST
  • Finds field list in HTML
  • Loops through domain values and queries for count on each field where value = domain value.
  • Writes domain description and number of results returned.
    • Will add notification if no results returned (!!!)

REST Search

REST Search

  • Add Search blank to HTML
  • Gets list of links to folders, services, and map service layers from REST
  • JSON Request through REST for each item in list
  • Searches specific JSON attributes based on whether the service is a folder, service, or layer
    • Lists attributes that match search blank
    • If more links to folders, services, and layers discovered, those are added to list to be searched

Select By Attributes

On the web

Select By Attributes

On the web

  • Create User interface for SQL parameters
  • Get field names and other properties from the layer
  • Select a text input or textarea to enter data
  • Click a field alias to enter field name
    • Also requests and presents 1000 unique results
    • Click result from list to add to query
  • Tracks cursor position when adding fields and SQL code

Quick Map Viewer

Quick Map Viewer

  • Load a map using the ArcGIS JavaScript API on the page.
  • When hovering over a link, load that layer into the map.
  • When hovering over the next link, destroy the previous map and recreate it with a the layer created from the next link.

Print Tasks Made Easy

Print Tasks Made Easy

  • Request REST JSON properties of the map service.
  • Replaces blanks with "choicesList" property to a select with choices in the choicesList added.
    • Formats (PDF, JPG, PNG, etc).
    • Layout_Templates
  • Adds a default Web Map as JSON string.

Future Improvements

Resources

  • ESRI REST Diagnostics
    • http://raykendo.github.io/ESRI_REST_Diagnostics/
  • Source code on Github
    • https://github.com/raykendo/ESRI_REST_Diagnostics
  • Tuts + bookmarklet tutorial
    • http://code.tutsplus.com/tutorials/create-bookmarklets-the-right-way--net-18154