19
A Sample Print Web Service Utilizing ArcGIS Server and ArcObjects Cheryl Spencer, IndyGIS Marianne Cardwell, Woolpert

A Sample Print Web Service Utilizing ArcGIS Server and ArcObjects Cheryl Spencer, IndyGIS Marianne Cardwell, Woolpert

Embed Size (px)

Citation preview

A Sample Print Web Service Utilizing ArcGIS Server and ArcObjects

Cheryl Spencer, IndyGISMarianne Cardwell, Woolpert

Overview

IndyGIS background Current web service useWhy the need for a print web service?

Business reasonsTechnological reasons

Nuts and boltsComponents of the Print Web ServiceHow components are used

Challenges & Lessons Learned

IndyGIS Background

Numerous internal applications and public applicationsArcGIS Server purchased in 2004Currently migrating to version 9.2Until recently have used ArcGIS Server behind the scenes to perform spatial analysis (non-map centric applications)

Current Web Services

Address ValidatorGeocodePoint In PolygonFind NearestFind Within RadiusPolygon AnalysisBuffer…and Print

Example Applications Using Web Services

Business Reasons for a Print Web Service

Target audience – DevelopersReusable print component can be used for all ArcGIS Server applications developed

Plug and Play• Saves time…and money

Consistent user experience when printing from a variety of applications.

Technological Reasons for a Print Web Service

Current ArcGIS Server technology does not provide for map printing functionality.Printing the page using the browser’s print functionality does not provide very good quality print-outs.Web service clearly separates out the print logic from the rest of the code.Print WS returns ArcMap-styled PDF map, including all elements one can expect in a map: scale, North arrow, legend, map, overview map, as well as text elements.

Components of the Print Web Service

How components are used

The first step is to create a layout in ArcMap.The second step is to export the layout to an XML file.

XML Configuration File

Custom ArcMap tool wizard created to convert an ArcMap layout to an XML document using a custom schema.Schema is read by Print Web Service to recreate the layout.

XML Configuration File

Example Use of Print Web Service

A web site utilizing an ArcGIS Server map control can use the Print WS to request a PDF map.Multiple parameters are requested, including the map description(s), map scale, map extent, text elements, and XML configuration file name.

Sample Web Interface

Print Web Service ProcessGet all parameters ready for the Web Service call:

Public Function ExportForUrl(ByVal textElements As TextElement(), _ ByVal pageConfigName As String, _ ByVal pageSize As String, _ ByVal pageOrientation As String, _ ByVal extent As Envelope, _ ByVal webMapScale As Double, _ ByVal mapServices() As MapService, _ ByVal overviewMapServices() As MapService, ByVal graphicElements() As GraphicElement, ByVal limitLegendLayers As Boolean, _ ByVal legendLayers() As String) As String

Print Web Service Process (cont’d)

Print WS goes through the following steps:

Create a Server Object ManagerCreate an empty Server ContextCreate (a) new IMap(s)Add layers to the map (re-created from MapDescription)Add graphics to the map

Print Web Service Process (cont’d)

Set up the page layout and the extent of the mapAdd all the page elements to the layout. These include:

• Map frames• Legends• North arrows• Scale bars• Text elements• Neatlines• Pictures• Scale texts

Export the map to PDF.

ChallengesArcObjects does not always respond the same way in a Web Service as it does in the Desktop environment. Don’t make too many assumptions.Legend was tricky. Spent a lot of time trying to get it right and required a lot of manual coding to resize it to the correct dimensions.Graphic layers with transparencies are not supported in ArcObjects (ArcMap) whereas they are in ArcGIS Server map controls (think of buffer overlays). Solution was to export the graphics to temporary shapefiles to apply transparency.

Lessons Learned

Do your homework.Document!Make it flexible.Put thought into web service signature.Think about error handling.Consider wrapping fine-grained ArcObjects calls into separate DLLs.

Questions?