2/26/2012
1
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGISLSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
LSGI 3421: GIS Applications
Dr. Bo Wu [email protected]
Department of Land Surveying & Geo-InformaticsThe Hong Kong Polytechnic University
Lecture 6:
Developing Applications with ArcGIS
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
1. Learning outcomes2. GIS Applications with ArcGIS3. ArcGIS Customization4. ArcObjects and MapObjects5. Developing GIS Applications with ArcObjects/
MapObjects6. Developing Web-GIS Applications with ArcIMS
Contents
2/26/2012 2
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• By the end of this lecture you should be able to:– Know the basic functions that ArcGIS can offer for a
GIS project– Perform customization exercises in ArcGIS – Know what are ArcObjects and MapObjects, and how
can they be used for developments– Know what is ArcIMS and how can it be used for web-
GIS development
Learning Outcomes
2/26/2012 3
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Desktop GIS Applications– ArcGIS Desktop is the primary platform for GIS
professionals to compile, use, and manage geographic information
• Web Mapping Applications– Bring multiple services together to create compelling
Web mapping applications.• Mobile GIS Applications
– Mobile GIS extends the reach of ArcGIS to a broad range of mobile devices including Tablet PCs, in-vehicle mounted systems, Windows Smartphones, and Apple iOS devices
GIS Applications with ArcGIS
2/26/2012 4
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• ArcReader, ArcView, ArcEditor, ArcInfo• ArcGIS Desktop: ArcMap, ArcCatalog, ArcScene, ArcToolbox, ArcGlobe
Desktop GIS Applications
2/26/2012 5
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Ready to use Web Apps– ArcGIS.com Viewer– ArcGIS Explorer Online
Web Mapping Applications
2/26/2012 6
• Configurable Applications– ArcGIS Viewer for Flex– ArcGIS Mapping for SharePoint
2/26/2012
2
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• ArcGIS Mobile• ArcGIS for iOS• ArcGIS for Windows Phone• ArcPad
Mobile GIS Applications
2/26/2012 7
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Customize ArcGIS Desktop interface without programming
• Customize and enhance ArcGIS Desktop using ArcObjects and VBA
• Incorporate ArcObjects to non-GIS applications using external development environment (VB, VC++, C#, …). The applications still need an ArcGIS license to run.
ArcGIS Customization
2/26/2012 8
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Customization without Programming
2/26/2012 9
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• In ArcMap– Map documents (.mxd files)– Normal (default) template (Normal.mxt)
• C:\Documents and Settings\<your username>\Application Data\ESRI\ArcMap\Templates\
– Base template (template other than the default )• In ArcCatlog
– Normal (default) template (Normal.gxt)
Save the Customization
2/26/2012 10
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Object Oriented Programming• Objects:
– Properties– Methods– Events
Fundamentals for Programming
2/26/2012 11
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Customization with Programming
2/26/2012 12
Example I: making a button to change the application caption
2/26/2012
3
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Customization with Programming
2/26/2012 13
Example II: making a tool to display (Lat, Long) on status bar
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Customization with Programming
2/26/2012 14
Example II: making a tool to display (Lat, Long) on status bar
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Customization with Programming
2/26/2012 15
Example II: making a tool to display (Lat, Long) on status bar
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Customization with Programming
Example III: making a button to turn all layers off
2/26/2012 16
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• ArcObjects is a collection of software components (objects) with GIS functionality and programmable interfaces.
• ArcGIS Desktop is built on ArcObjects.• ArcObjects software components expose the
full range of functionality of ArcGIS to software developers.
What is ArcObjects?
2/26/2012 17
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcGIS Object Model
2/26/2012 18
All ArcObjects object diagrams(pdf files) can be found in“ArcObjects Developer Help”.
2/26/2012
4
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Dim pMxDoc As IMxDocumentSet pMxDoc = ThisDocument
Dim pMap As IMapSet pMap =pMxDoc.FocusMap
Dim Player as ILayerSet pLayer = pMap.Layer(0)
ArcGIS Object Model
2/26/2012 19
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Visual Basic for Applications (VBA)– A simplified version of Microsoft Visual Basic (VB)– An object-oriented programming language– Included in ArcGIS Desktop (ArcMap, ArcCatlog)– Designed to be embedded within application
• Other Methods (VB, VC++, C#, …)
Developing with ArcObjects
2/26/2012 20
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• What is MapObjects?– MapObjects is an ActiveX control (OCX) with nearly 50
programmable ActiveX automation objects that can be plugged in to many standard Windows development such as Visual Basic, Visual Basic for Applications (VBA), Visual C++, Visual Studio.NET (VB.NET and C#), Delphi, Borland C++ Builder, Visual FoxPro, and PowerBuilder.
– MapObjects Windows Edition, MapObjects Java Edition, and MapObjects LT.
• Why MapObjects?– GIS is a small portion of a large application system– Handy functions in other Windows software– Simple mapping or query applications
MapObjects
2/26/2012 21
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcObject vs MapObject
2/26/2012 22
• MapObjects is deployable without any other installation, but ArcObjects requires a full ArcGIS Desktop installation.
• MapObjects is much simpler than ArcObjects , in terms of object number and complexity.
• ArcObjects can do much more funzy rendering and display than MapObjects. Yet MapObjects has samples to create your own renderers, but it is not that simple.
• ArcObjects implements a lot of Interfaces in COM. Programming ArcObjects must deal with these interfaces and to ensure you got the right one.
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Draw and Display– Display a map with multiple map layers.– Render features with thematic methods.– Label features with text from field values.– Draw images from aerial photography or satellite imagery.– Pan and zoom throughout a map.– Draw graphics and descriptive text.– Dynamically display real-time or time-series data.
• Create new shape files• Query and analysis
– Select features according to graphics. – Select features with an SQL expression. – Calculate basic statistics on selected features.– Query and update attribute data associated with selected features.– Type in an address and find a location on a map.– Project your data into different coordinate systems.
What You Can Do with MapObjects?
2/26/2012 23
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Standard GIS formats--ArcInfo coverages, ESRI shapefiles, and ESRI GRIDCAD formats (DGN, DXF, and DWG)Access to external databases through ActiveX Data Objects (ADO), Data Access Objects (DAO), and Open Database Connectivity (ODBC)Image catalogs, plus a variety of image formats such as GeoTIFF, TIFF, JPEG, GIF, ERDAS Imagine, and MrSID ESRI's ArcView StreetMap for geocodingArcSDE (ESRI's Spatial Database Engine) databases Common military formats such as Vector Product Format (VPF) and ASRP/USRP
Data Formats Supported by MapObjects
2/26/2012 24
2/26/2012
5
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Data Access Objects: – Access geographic data from database
• Map Display Objects: – Display data on 2D map
• Geometric Objects: – Create and manipulate points, lines, polygons …
• Utility Objects: – Manipulate text strings
• Projection Objects: – Map projection
• Address Matching Objects: – Geocoding/address matching
Objects in MapObjects
2/26/2012 25
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Access MapObjects in Visual Basic
2/26/2012 26
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
MapObjects Developing with VB
2/26/2012 27
An example: adding and displaying a map
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
There are 30 samples and a document (GettingStartedwithMOinVB.doc) in \MapObjects2\Samples\VB\.
MO Legend Control:legMapDisp
MO Map Control: mapDisp
MapObjects Developing with VB
2/26/2012 28
An example from ESRI (\MapObjects2\Samples\VB\MoView2)
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
An example: Add a shapefile
MapObjects Developing with VB
2/26/2012 29
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
An example: Add an image and a grid
MapObjects Developing with VB
2/26/2012 30
2/26/2012
6
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
'Determine the legend's active layerIf mapDisp.Layers.count > 0 And legMapDisp.getActiveLayer > -1 Then
Set g_ActiveLayer = mapDisp.Layers(legMapDisp.getActiveLayer)Else
Set g_ActiveLayer = NothingEnd IfIf g_ActiveLayer Is Nothing Then
MsgBox "No active layers.", vbCriticalExit Sub
End IfmapDisp.Extent = g_ActiveLayer.Extent
• Zoom to full extentmapDisp.Extent = mapDisp.FullExtent
• Zoom to active layer extent
MapObjects Developing with VB
2/26/2012 31
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
MapObjects Developing with VB
2/26/2012 32
Zoom In, Zoom Out and Pan
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
MapObjects Developing with VB
2/26/2012 33
Draw text, point, line, rectangle, polygon, and circle
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
A Flash demo at: http://gis.esri.com/esriclips/clip.cfm?ClipID=61
An Example Developed with MapObjects
An example developed based on MapObjects, Visual Basic, MS SQL Server and MS Access
2/26/2012 34
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• What is ArcIMS?– ArcIMS is a solution for delivering dynamic maps and GIS data
and services via the Web. It provides a highly scalable framework for GIS Web publishing
• With ArcIMS, you can– Deliver dynamic maps and data via the Web– Share data with others to accomplish tasks
• Other Web GIS Software– Autodesk MapGuide– MapInfo MapX– Intergraph GeoMedia WebMap– GeoServer or MapServer (Free)– …
ArcIMS
2/26/2012 35
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcIMS Architecture
Accessing, viewing, and analyzing geographic data.
Handling requests and administering the ArcIMS site.
Accessing to components in the business logic tier for authoring maps, administering ArcIMS services and Spatial Servers, and designing Web sites.
2/26/2012 36
2/26/2012
7
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
A Web server handles request from a client using HTTP. It forwards a request to the appropriate application and sends a response back to the requesting client.
A JavaVM provides the application programming interface (API) for running these applications.
A servlet engine is an extension to the JavaVM and provides support for servlets through a servlet API. The servlet engine plugs into a web server and provides the link between the JavaVM and the Web server.
Components of ArcIMS
2/26/2012 37
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
How Does a Web Server Connect to ArcIMS Application Server?
The ArcIMS Connectors provide a communication pipeline between a Web server and the ArcIMS Application Server.
2/26/2012 38
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• ArcIMS Connectors generate ArcXML before sending request to the ArcIMS Application Server.
• ArcXML is an implementation of XML. It provides the structure for map configuration files, metadata configuration files, requests, responses and administration.
How Does a Web Server Connect to ArcIMS Application Server?
2/26/2012 39
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Maps are generated on the server and send to clients as JPEG, PNG, or GIF image.
• Vector features from shapefiles and ArcSDE data sets are streamed in a compressed format to a Java Applet in the client Web browser or to other ESRI products. It allows for many functional capabilities on the client.
The Image, Feature, Metadata, and ArcMap Servers are public and can beaccessed through the ArcIMS interface. The Query, Geocode, and Extract Serversare private and are managed automatically by the Spatial Server when they areneeded. There is no user interface to these servers.
ArcIMS Spatial Server
2/26/2012 40
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Image Services– An Image Service uses the Image Server. – When a request is received, a map is generated by the Spatial Server
and sent to the client as an image. – A new map image is generated each time a client requests new
information. – Image Services have internal access to the Query, Geocode, and
Extract Servers depending on what functionality is required to process the request.
• Feature Services– A Feature Service uses the Feature Server. – Rather than a map being rendered on the server, data is bundled and
streamed to the requesting client. – Since more of the processing is done in the client, requests are sent to
an ArcIMS Spatial Server only when additional data is needed.– Feature Services have internal access to the Geocode and Extract
Servers for handling geocode and extract requests, respectively.
ArcIMS Services
2/26/2012 41
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Generating a map configuration file for image and/or feature service• Publishing and administering ArcIMS services• Designing Web pages• Customizing ArcIMS client viewers
Creating and Managing an ArcIMS Site
2/26/2012 42
2/26/2012
8
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Designing Web Pages
The output from Designer is a group of HTML files and JavaScript files.
2/26/2012 43
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcIMS Viewers
HTML Viewer
Java Viewer
2/26/2012 44
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
HTML Viewer
Example HTML Viewer
• HTML Viewer is written using HTML, DHTML, and JavaScript.
• Only one Image Service (or ArcMap Image Service) can be displayed at a time.
• All requests are generated using JavaScript, and all responses are parsed using JavaScript.
• The client browser must be Internet Explorer or Netscape.
2/26/2012 45
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Example Java Custom Viewer
• ArcIMS comes with two Java Viewers: Java Custom and Java Standard.
• Java Viewers supports Image, ArcMap Image, and Feature Services. Multiple services can be combined with local data and viewed in the same Java Viewer.
• The Java Custom Viewer uses JavaScript and can be customized using Viewer Object Model API. It is only supported on Internet Explorer.
• The Java Standard Viewer does not use JavaScript and can not be customized. It is supported on Netscape and Internet Explorer.
• The Java Viewers use a Java 2 Applet for displaying the information and processing requests. They require two downloads: Java plug-in and the needed ArcIMS Viewer components.
Java Viewers
2/26/2012 46
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• ArcIMS Designer creates output files, including HTML and JavaScript files (.js), that form the foundation of the HTML Viewer. HTML files are used to generate Web page content, and the JavaScript functions allow for user interaction with the map
• You may want to customize HTML Viewer in the following ways:– Changing the frame layout– Modifying the toolbar– Adding functionality– Changing the graphic look– Inserting your own company logo
Customizing ArcIMS HTML Viewer
2/26/2012 47
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
ArcIMS HTML Viewer Frames
2/26/2012 48
2/26/2012
9
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Changing Frame Layout
2/26/2012 49
viewer.htm
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
viewer.htm
// Change the title
// var theTitle = "ArcIMS Viewer";
var theTitle = “Local Maps";
top.htmChanging the logo and background on the topFrame
Working with HTML Files: Examples
2/26/2012 50
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
Working with ArcIMSparam.js
ArcIMSparam.js includes, but is not limited to, variables for
• Changing services and map extents
• Setting the initial display of the legend
• Defining North arrows and copyright text on an acetate layer
• Defining fields for attribute display
• Changing tools and the toolbar
2/26/2012 51
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
//initial map extent
var startLeft = -45.005;
var startRight = 100.005;
var startTop = 100.005;
var startBottom = -40.005;
//maximum map extent
var limitLeft = -1214.892;
var limitRight = 707.508;
var limitTop = 1244.3436;
var limitBottom = -678.0564;
//Modifing the toolbar
var usePan=true;
var usePanNorth=true;
var usePanWest=true;
var usePanEast=true;
var usePanSouth=true;
var useZoomIn=true;
var useZoomOut=true;
var useFullExtent=true;
var useZoomActive=true;
var useZoomLast=true;
var useIdentify=true;
var useMeasure=true;
var useSetUnits=true;
var useSelect=false;
var useQuery=false;
var useFind=false;
var useGeocode=false;
var useStoredQuery=false;
var useClearSelect=true;
var usePrint=true;
var useGeoNetwork=false;
var useBuffer=false;
var useExtract=false;
Working with ArcIMSparam.js: Examples
2/26/2012 52
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
// North Arrow
var drawNorthArrow = true;
var NorthArrowType = "4";
var NorthArrowSize = "15";
var NorthArrowCoords = "20 35";
var NorthArrowAngle = "0";
// Scale Barvar drawScaleBar = true;
// MapUnits=DEGREES,FEET,METERS// can MapUnits be changed by user?
var setMapUnits=false;ScaleBarUnits=KILOMETERS,METERS,MILES,FEETvar ScaleBarBackground = "false";var ScaleBarBackColor = "0,0,0";var ScaleBarFontColor = "0,0,0";var ScaleBarColor = "128,128,128";var ScaleBarFont = "";var ScaleBarStyle = "Regular";var ScaleBarRound = "1";var ScaleBarSize = "9";var ScaleBarWidth = "5";var ScaleBarPrecision = 2;var numDecimals = ScaleBarPrecision;
// Changing units
var MapUnits = "METERS";
var ScaleBarUnits = "METERS";
Working with ArcIMSparam.js: Examples
2/26/2012 53
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
An Example
2/26/2012 54
2/26/2012
10
LSGI 3421: GIS Applications Lecture 6: Developing Applications with ArcGIS
• Further readings– ArcGIS Applications.
(http://resources.arcgis.com/content/arcgisserver/9.3/server-applications)– ArcGIS Web Apps (http://resources.arcgis.com/content/web/web-apps)
• Summarization of the main ideas presented in this lecture:
• Questions?
Review
2/26/2012 55