Developing Applications with ArcGIS Server Using the Microsoft .NET Framework
Mark Ho Kevin Deege
Agenda
• • • • • • •
Introduction to the Web ADF Web Controls Extending the Toolbar Control Developer API’s Web ADF Tasks Highlights of 9.3.1 Q&A
ArcGIS Server 9.3 Complete and Interoperable Server-Based GIS
Use Serve
ArcGIS Server
Author ArcGIS Desktop
GIS on the Web in 3 steps n Author GIS content – Create GIS resources – ArcGIS Desktop applications
o Publish content – Publish GIS resources as services – ArcCatalog and ArcGIS Server Manager
p Use GIS services – Web mapping applications – ArcGIS Explorer – ArcGIS Desktop – Many others
GIS Services are created from GIS Resources Service type
Published using
Map
Map document (.mxd or .pmf)
Globe
Globe document (.3dd)
Geocode
Locator (.loc file or geodatabase)
Geodata
Geodatabase connection (.sde) or Map document with geodatabase layer
Geoprocessing
Toolbox (.tbx) or Map document (.mxd) with tool layer
Image
Raster dataset or layer file (.lyr) or image service file (.iscdef)
ArcGIS Server Web Development Options for building web clients
Web Map App
JavaScript
Web ADF
SilverLight
REST
ArcGIS Server
Flex
Web ADF Development 101 What do you need to know?
• Client and Server side web development – ASP.NET (C#, VB.NET) – HTML/CSS – ASP.NET AJAX • Partial Postbacks • Javascript • Application Services
• Familiar with IIS – Performance, Scalability, ASP.NET worker process
Web ADF Development 101 Development Configuration
• Web server (IIS) • Visual Studio .NET – 2005/2008 – .NET Framework – 2.0/3.0/3.5
• • •
ASP.NET AJAX extensions Web Application Development Framework (ADF) Access to GIS server required – Local or remote
ArcGIS Resource Centers Developer Help
• • • • •
Developer SDK’s Sample GIS Server ArcGIS Online Online Help Community – Blogs & Forums – Code Gallery
• Support – Knowledge Base – Software updates
http://resources.esri.com
ArcGIS Server Resource Center
DEMO
Introducing the Web Application Developer Framework (ADF) • • •
.NET libraries used to build GIS Web applications Web ADF Javascript Web controls – Mapping, resource management, multi-source – AJAX enabled
• Task framework – Extensible Architecture
• Visual Studio integration (2005 and 2008) – Toolbox panel – Context menus – Developer Help – Developer Samples – Web Mapping Application template
Web Application Developer Framework
Web ADF developer libraries
• Assemblies – Web ADF (native .NET) – ArcObjects (COM Interop)
• ArcObjects COM type libraries
Web ADF Controls
• AJAX enabled • Multi-source consolidation – Resource blending
• Rich out-of-the-box functionality
• Visual Studio integration
Web ADF JavaScript
• Enhances the Web ADF Web Controls and Framework – Client side functionality and behaviors
• Built using ASP.NET AJAX as the base client library – Support for well known MS AJAX Patterns – Documention provided on MSDN
• Event Driven – Respond to map events directly in browser using a Scriptable Map Control
• Object Oriented – Full object model and SDK detailing how to use it
ASP.NET AJAX and 9.3
9.3 9.2
Client-side
Server-side
ArcGIS Server .NET Web ADF Web Web ADF ADF JavaScript JavaScriptLibrary files Microsoft.NET ASP.NET AJAX Microsoft Framework
Microsoft AJAX Library
Microsoft .NET Framework
Web ADF Data Sources
• • •
Generic framework for supporting multiple Services Manages interaction between Web controls and data sources Extensible architecture
Web ADF Graphics
• Drawn on top of layers in the map • Used to perform tasks such as: – Highlighting features (select) – Labeling text – Displaying buffers – Geocoding – Displaying dynamic data (GPS)
• Rendering occurs independently from the map – Does not require a map redraw
Web ADF Tasks
• • • •
Visual components Perform set of related actions Generate results Encapsulate workflow – Provide user interface (UI) for gathering input – Perform some action based on inputs – Generate results
The ADF Task Framework
• Framework provides for: – Configuring tasks in VS.NET and Manager – Organization of tasks – Feedback when a task is executing – Management of results • Display • Visualization on Map • Delete, Refresh, Re-run
– Distributable UI components • Plugs into Manager
• Extensible io d u t lS a su Vi
Custom Task
r ge a n Ma
Web ADF development paths
• Web Mapping Application Template • Web ADF Web controls • Developer API’s – Common data source API – SOAP – ArcObjects
Options for creating Web ADF applications
• ArcGIS Server Manager – Set required parameters – Map, table of contents – Theme, hyperlinks – Can modify in Visual Studio
• Visual Studio template – Same files as ArcGIS Server Manager
• ASP.NET Web Site – Create with Web Controls
Advantages of using the template
• Start with a complete GIS Web application • The template provides: – Measure user control – Identify tool – Layout DIVs – resize, etc. – Docking items – Themes – Help system
Web Mapping Application Template Themes
• Property settings – Assigned in web.config
• Stored in App_Themes
• Components – Images – Skins (.skin) – Cascading Style Sheets (CSS)
Web Mapping Application
DEMO
Getting started with Web ADF controls
• Resource manager controls – Not visible at run time – Manage resources
• Mapping controls – Map – Overview map
• Related controls – Toolbar – Table of contents
Map resource manager
• Manages a collection of resource items – Resource definition • Name displays in the table of contents • Type determines the data source
– Display settings • • •
Transparency Background color Request MIME data
Map control
• Associate with a Map resource manager control • Works with multiple map resources – Create dynamic map images – Fetch pre-generated image tiles (cached services)
• Image blending – Web tier or browser
• Game-style navigation – Seamless pan and zoom – Keyboard and mouse integration
Toolbar control
• Contains collection of toolbar items – Tool – Command – DropDownBox – Separator – Space
• At run time, displays collection of tools – Out-of-the-box – Custom
• Buddy with Map or PageLayout control
Toc control
• • • •
Lists map layers Supports multiple data sources Buddy with Map or PageLayout control Inherits TreeViewPlus control – Supports Extensible Markup Language (XML) databinding
• Asynchronous
OverviewMap control OverviewMap control
• Shows interactive area of interest • Displays GIS resources – Can differ from map
• StaticMode boolean – True: Re-use map image – False: Regenerate map image
• Buddy with a Map control – Uses a MapResourceManager – Same spatial reference
Map control
MapTips control
• • •
Displays attributes Creates interactive graphics Map service must return geometry – Points, lines, polygons
• Works with – ArcGIS Server – ArcIMS – Web ADF graphics
• Buddy with Map control
ContextMenu control Design time
• Associate with any element in the page • Set ContextMenu properties – BackColor makes control visible at runtime – Other properties are optional
• Write code to: – Add context menu items – Show context menu at runtime – Handle click event
Run time
Other controls
• FloatingPanel – Container for other Web controls – Rendered as CSS in browser
• Magnifier – Floating window over Map control – Zoom to main map
• ZoomLevel – Pre-defined map scale intervals – Cached and dynamic services
• Navigation – Pre-defined pan speed
Web ADF Web Controls
DEMO
Working with the Web ADF JavaScript Library
• • •
Public script API of Web ADF controls Built on Microsoft ASP.NET AJAX Web ADF server controls are scriptable – Represented in JavaScript as components – Use JavaScript to interact with control on the client-side
• Client-side object model – Geometry – Symbology – Layers (server-side and client-side) – Callouts and MapTips
Getting started with the Map client control
• Access the Map using JavaScript • Set properties (get_ and set_) – extent, mouseMode, layers
• Call functions – Navigation: zoom, zoomTo, panTo – Graphics: addGraphic, removeGraphic – Geometry: getGeometry
• Event handlers (add_event, remove_event) – click, extentChanged, onProgress
Web ADF JavaScript Examples
• Get the map object and add an event listener
• Center map on a point var center = new ESRI.Geometries.Point(100,0) map.panTo(center);
Web ADF JavaScript OMD
var map = $find('Map1'); MapControl ID var scaleFactor = 2; var centerPoint = new ESRI.ADF.Geometries.Point(-110, 45); var useAnimation = true; map.zoom(scaleFactor, centerPoint, useAnimation);
Web ADF JavaScript
DEMO
40
Developer API’s – Common Data Source
• ArcGIS Server supports multiple data sources – ArcGIS Server, ArcIMS, ArcWeb services, OGC, Graphics
• Common Datasource API – Pure .NET classes for the Web ADF – Access and interact with all data sources the same way
• Provides different functionalities - query, find, identity…
Common data source API
Advantages of the Common Data Source API
• • • •
Removes business and GIS logic from Web controls Support for multiple data sources using the same API Easy to program against different data sources Implement your own custom data sources
Data source-specific APIs
ESRI.ArcGIS.ADF.ArcGISServer.dll ESRI.ArcGIS.ADF.IMS.dll ESRI.ArcGIS.ADF.ArcWebService.dll
• Support for data source specific capabilities – ArcGIS Server – ArcIMS – ArcWeb Services
• Example: ArcObjects API – Access to the fine-grained ArcObjects
• What does this mean? – Many other data sourcespecific classes available – More business/GIS logic – Different APIs use different communication protocols – Requires different programming patterns for each data source
Extending the Web ADF toolbar
• Toolbar items execute client and server actions • Command (like a button) – A click invokes server action
• Drop-down box – Select item to invoke server action – List layer names, data frames, etc.
• Tool – Client-side action: Action performed in Web browser – Server-side action: Class to handle server tool action
Creating a custom tool
1. 2. 3. 4. 5.
Make a toolbar Add controls to it Choose a JavaScript for client-side action, if needed Create a class for the control’s server-side code Set control’s properties to connect to its client and server code
Creating controls on a toolbar
• Toolbar properties • ToolbarItems property • The Add button – Items to Contents – Builds the toolbar
Define Client-side Action
• The user ‘draws’ a shape with the tool • You decide which shape by setting ClientAction property – Rectangle – Line – Point – Polygon – Circle – Oval
Writing code for your tool
• • •
Create a class in App_code folder for the server action Implement IMapServerToolAction Use args paramater to get the Map
Sub Sub ServerAction(ByVal ServerAction(ByVal args args as as ToolEventArgs) ToolEventArgs) Dim Dim map map as as Map Map == CType(args.Control,Map) CType(args.Control,Map) Dim pargs as PointEventArgs Dim pargs as PointEventArgs == CType(args,PointEventArgs) CType(args,PointEventArgs) map.CenterAt(pargs.ScreenPoint) map.CenterAt(pargs.ScreenPoint) End End Sub Sub
Associating the code (the class) to a control
• • • •
ToolbarItemsCollectionEditor Show Properties ServerActionAssembly ServerActionClass
Extending the Web ADF Toolbar
DEMO
Leveraging the task framework Page developer
• Page developer – Use out-of-the-box tasks – Add results directly to TaskResults container • Custom tools
Out-of-the-box Web controls
Page/Web control events
Custom Actions/Events
User controls
– Create User control
• Server control developer – Extend existing tasks to modify behavior – Develop custom task to distribute and integrate with ArcGIS Server Manager
Server control developer Extend Web controls
Composite Web controls
Tasks included with the ADF
• Configure without writing code – Similar to ArcGIS Server Manager
• Common tasks – Search Attributes – Query Attributes – Print – Find Address
• Resource-specific tasks – Find Place – Geoprocessing – Editor
TaskManager control
• Organizes tasks in a Web application • Generates hierarchical XML at run time – XML can be bound to ASP.NET menu or tree view – BuddyControl property controls binding
Design time
Run time
XML + System.Web.UI.WebControls.Menu =
TaskResults control
• • •
Displays task results as nodes in tree view Draws results in a map Produces interactive results – Highlight feature as result set – Zoom or pan to feature – Re-run task – Remove task results
• Handles events for nodes – Add, click, select, remove
Custom Web Task Implementation
• Basic task implements ITask • Create a custom Web control – Extend Task or FloatingPanelTask abstract base classes CustomTask
ICallbackEventHandler ESRI.ArcGIS.ADF.Web.UI.WebControls FloatingPanelTask
ESRI.ArcGIS.ADF.Web.UI.WebControls FloatingPanel
ASP.NET Web Controls
IBuddyControlSupport ITask
Web ADF Task Framework
DEMO
What’s New at 9.3.1
• Map Tips templates • Additional Resources – Image Server – Virtual Earth
• User Control Tasks • Print Task templates • Manager Customization – Custom Panels
Additional Resources • Developer Summit Proceedings – Archived recordings and presentations – http://gis.esri.com/library/userconf/devsummit08/index.html
• ArcGIS 9.3 On-line Seminars – View a free Live Training Seminar or watch the recording – www.esri.com/lts
• ArcGIS Server Training – Introduction to ArcGIS Server – Developing Applications with ArcGIS Server for the Microsoft .NET Framework – www.esri.com/training
Questions and Answers
Please fill out your evaluations