Autodesk 15606-011408-9300 Developer Guide

Autodesk 15606-011408-9300 - MAPGUIDE R6.3 UPG Manual

Autodesk 15606-011408-9300 manual content summary:

  • Autodesk 15606-011408-9300 | Developer Guide - Page 1
    Autodesk MapGuide® Release 6 Developer's Guide 15306-010000-5060 October 2001
  • Autodesk 15606-011408-9300 | Developer Guide - Page 2
    Copyright © 2001 Autodesk, Inc. All Rights Reserved AUTODESK, INC. MAKES NO WARRANTY, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, REGARDING THESE MATERIALS AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN "AS
  • Autodesk 15606-011408-9300 | Developer Guide - Page 3
    1 Introduction 7 What's New in Release 6 8 Autodesk DWG Data Source Support 8 Enhanced Support for Map Redraw Operations 8 Symbol Bitmap Support 8 Map Mode Retrieval Support 9 Java Edition Platform Support Changes 9 Before You Begin 9 Familiarity with Autodesk MapGuide 9 Programming and
  • Autodesk 15606-011408-9300 | Developer Guide - Page 4
    Map Access for the Java Edition 35 Map Access from HTML 35 Map Access Using Java 38 Required Software for the Java Edition 39 Java Edition Differences 39 Communicating with the Plug-In from a Java Applet 40 Accessing Secure Data 43 Handling Busy State and Map Refresh 43 About the Busy State
  • Autodesk 15606-011408-9300 | Developer Guide - Page 5
    Writing Event Handlers 78 Page Setup Event Handler Example 79 Print Event Handler Example 81 Plug-In Event Handler Example 83 Chapter 6 Using Reports to Query and Update Data Sources . . . . . 85 Overview 86 How Reports Are Generated 86 Specifying the Report Script 86 The Request 87
  • Autodesk 15606-011408-9300 | Developer Guide - Page 6
    vi
  • Autodesk 15606-011408-9300 | Developer Guide - Page 7
    need to create, publish, and display maps and associated attribute data over the Web. The Autodesk MapGuide Developer's Guide is a complete guide to Autodesk MapGuide customization and development features. This chapter introduces Autodesk MapGuide application development, and describes how to use
  • Autodesk 15606-011408-9300 | Developer Guide - Page 8
    one new object and several new and changed methods and properties to support new and enhanced features. For detailed information about the new object, the Autodesk MapGuide Viewer redraws a map. Maps are now updated every 1.5 seconds by default. This allows the end user to view changes to the map as
  • Autodesk 15606-011408-9300 | Developer Guide - Page 9
    a map's mode, such as zoom, pan, and so on. Java Edition Platform Support Changes Autodesk MapGuide Viewer, Java™ Edition does not run if you are using Microsoft® read the first few chapters of the Autodesk MapGuide User's Guide to make sure you understand the product, especially emphasizing the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 10
    about this toolkit, refer to the Dynamic Authoring Toolkit Developer's Guide. Your Audience As with all development, the most important aspect Will they need redlining? Are they computer savvy, or will you need to guide them through basic usage of your application? Do they have much domain knowledge?
  • Autodesk 15606-011408-9300 | Developer Guide - Page 11
    User Help If you want to provide information about your application that users can readily access, you can develop your own set of Help pages. You can then set up the map to point to your customized Help system instead of the default Autodesk MapGuide Viewer Help when users click the Help button or
  • Autodesk 15606-011408-9300 | Developer Guide - Page 12
    controlling the map and its data. In most cases, you will write your application code within one or more HTML pages using one of the supported languages (refer to "Choosing a Viewer/Browser Environment" in the Autodesk MapGuide User
  • Autodesk 15606-011408-9300 | Developer Guide - Page 13
    Autodesk MapGuide Viewer API Help For complete information about the Autodesk MapGuide Viewer API, refer to Autodesk MapGuide Viewer API Help, available from the Autodesk MapGuide CD and the Autodesk MapGuide documentation page at the following web site: www.autodesk.com/mapguidedocs. The Autodesk
  • Autodesk 15606-011408-9300 | Developer Guide - Page 14
    's date and update the source database, so that all other technicians viewing that power pole on the map would see the new date of last service. For more information about reports, see Chapter 6, "Using Reports to Query and Update Data Sources." You can also enable users to mark up the maps
  • Autodesk 15606-011408-9300 | Developer Guide - Page 15
    Creating an Autodesk MapGuide Viewer API Application The following table summarizes tasks involved when creating an Autodesk MapGuide Viewer API application. For examples of real-world applications, also see Chapter 7, "Applications." Application Type Task For more information... Simple
  • Autodesk 15606-011408-9300 | Developer Guide - Page 16
    16
  • Autodesk 15606-011408-9300 | Developer Guide - Page 17
    Displaying Maps 2 This chapter describes how to link to or embed a map in a Web page for display in Autodesk MapGuide® Viewer ActiveX Control, Autodesk MapGuide Viewer Plug-In, or Autodesk MapGuide Viewer, Java Edition. Once your application can display a map, you can access the map
  • Autodesk 15606-011408-9300 | Developer Guide - Page 18
    Viewer, Java Edition), depending on which ones you support. If your users are unable to download or The Autodesk MapGuide Viewers you choose to support depend on the browser operating environment of depend on the Autodesk MapGuide Viewers you support. For a detailed discussion of these options
  • Autodesk 15606-011408-9300 | Developer Guide - Page 19
    Browser/Viewer Configurations Operating System Browser Windows Internet Explorer Netscape Navigator Mac OS Solaris None (stand-alone application) Internet Explorer Netscape Navigator Client-Side Viewer Programming or Scripting Language Autodesk MapGuide Viewer ActiveX Control HTML,
  • Autodesk 15606-011408-9300 | Developer Guide - Page 20
    Map Display for ActiveX Control and Plug-In To display your map with Autodesk MapGuide Viewer ActiveX Control and/or Autodesk MapGuide Viewer Plug-In, you can either: I Link to the map, or I Embed the map (the map runs inside a Web browser) Linking to a Map You can display a map by creating a link
  • Autodesk 15606-011408-9300 | Developer Guide - Page 21
    Map in a Different Window or Frame To display the linked map in a different window or frame, use the TARGET parameter. If necessary, open the second window or frame so that the original document can continue to be displayed. For example:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 22
    Embedding a Map A second way to display a map is to embed it in an HTML page. Embedding a map displays it with the rest of the information on that page.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 23
    Embedded map Embedding a Map in a Frame-Based Page To display a map within a frame-based page, use the tag to reference an HTML document that embeds the map. When you display a map within a frame, the size of the map can grow and shrink as the window is resized. To see an example of a map
  • Autodesk 15606-011408-9300 | Developer Guide - Page 24
    Here is an example HTML page for map.htm referenced by the frame set: Map.htm
  • Autodesk 15606-011408-9300 | Developer Guide - Page 25
    To display your map with Autodesk MapGuide Viewer, Java Edition 1 Start with the standard HTML tag. 2 Set the CODE parameter to the path to the MGMapApplet.class file in the com.autodesk.mgjava package. This package is where the API for Autodesk MapGuide Viewer, Java Edition resides. You
  • Autodesk 15606-011408-9300 | Developer Guide - Page 26
    complete information on implementing Autodesk MapGuide LiteView, refer to the Autodesk MapGuide LiteView Developer's Guide. The following table summarizes the supported configurations for Autodesk MapGuide LiteView: Autodesk MapGuide LiteView Configurations Operating System Browser Server-Side
  • Autodesk 15606-011408-9300 | Developer Guide - Page 27
    Installing Viewers on Client Machines If users accessing your Web site don't have an Autodesk MapGuide Viewer installed on their system, they need to download one in order to view the map you have displayed in the Web page. You can include code in your HTML file that automatically detects whether or
  • Autodesk 15606-011408-9300 | Developer Guide - Page 28
    To install the Autodesk MapGuide Viewer Plug-In 1 To install the latest version of Autodesk MapGuide Viewer Plug-In for Netscape Navigator users, write additional code to prompt the user to download Autodesk MapGuide Viewer Plug-In, as follows: To download Autodesk MapGuide Viewer Plug-In // Call
  • Autodesk 15606-011408-9300 | Developer Guide - Page 29
    To install the Autodesk MapGuide Viewer, Java Edition 1 To check a client machine for Autodesk MapGuide Viewer, Java Edition, include the following applet in the HTML page that displays your map:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 30
    30
  • Autodesk 15606-011408-9300 | Developer Guide - Page 31
    Accessing Maps 3 This chapter describes how to programmatically access maps you have embedded in a Web page. Once your application can access a map, you can begin to expand your application to work with map layers, map features, and printing as described in Chapter 4, "Working with Map Layers, Map
  • Autodesk 15606-011408-9300 | Developer Guide - Page 32
    Explorer® expose map objects at different levels in their object hierarchies. Therefore, how you access a map is determined by the browsers you are supporting, not by the version of Autodesk MapGuide® Viewer you use. As described in this chapter, you can write a simple function that checks the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 33
    If your embedded map had the name map, the code to access the map on a simple, frameless HTML page would look like this: function getMap() { if (navigator.appName() == "Netscape") return document.map; else return window.map; } If your application had
  • Autodesk 15606-011408-9300 | Developer Guide - Page 34
    Because getMap has an MGMap object as its return value, you can use the function in place of MGMap, accessing that object's methods or properties as needed. Warning Because Netscape Communicator 4.x contains the Same Origin security policy, the map object cannot be accessed by the Autodesk MapGuide
  • Autodesk 15606-011408-9300 | Developer Guide - Page 35
    tag. This approach provides the following benefits: I You can post a map that most browsers and operating systems can access. I This is the simplest way to support Autodesk MapGuide Viewer, Java Edi- tion. All you have to do is use the standard HTML tag and set MGMapApplet as the code value
  • Autodesk 15606-011408-9300 | Developer Guide - Page 36
    across all browser/operating system combinations. Internet Explorer has the following limitations: I Internet Explorer 4.0 for Mac OS does not support JavaScript. It supports JScript, but JScript cannot control a Java applet. I Because Internet Explorer exposes applets as COM objects instead of Java
  • Autodesk 15606-011408-9300 | Developer Guide - Page 37
    you need more interactivity with the map, you will need to use Java instead, as described below. This is particularly important if you need to support Macintosh users, as they will need to use the Autodesk MapGuide Viewer, Java Edition with Internet Explorer, which doesn't have full JScript
  • Autodesk 15606-011408-9300 | Developer Guide - Page 38
    Viewer, Java Edition from a wrapper applet, because, with a peer java applet, Autodesk MapGuide Viewer, Java Edition is automatically provided with browser services such as showDocument. Another benefit is that Autodesk MapGuide Viewer, Java Edition and the peer applet can exist in separate frames
  • Autodesk 15606-011408-9300 | Developer Guide - Page 39
    Required Software for the Java Edition To work with Autodesk MapGuide Viewer, Java Edition, you may need to download certain Java files provided with Autodesk MapGuide. Specifically, you will need to access the Autodesk MapGuide Viewer, Java Edition API, which resides in the com.autodesk.mgjava
  • Autodesk 15606-011408-9300 | Developer Guide - Page 40
    different protocols in the Java network library (the previous example illustrates that Internet Explorer does not support the JavaScript protocol in the Java network library). Communicating with the Plug-In from a Java Applet Netscape's LiveConnect technology makes it possible to write a Java
  • Autodesk 15606-011408-9300 | Developer Guide - Page 41
    Accessing the Plug-In from a Java Applet You can access Autodesk MapGuide Viewer Plug-In from your Java applet. To access Autodesk MapGuide Viewer Plug-In 1 Copy the npmapv32.zip file installed in your Netscape Plugins folder to a folder in your Java development environment, so that your Java
  • Autodesk 15606-011408-9300 | Developer Guide - Page 42
    This code calls the Init function, which is placed within the onLoad event, which is inserted into the BODY tag. This prevents errors by loading the map before any code tries to access it. Init passes the embedded map object into the setMap function in the applet. Now you can make any API call to
  • Autodesk 15606-011408-9300 | Developer Guide - Page 43
    Accessing Secure Data Map authors can control whether developers can use the getVertices and getLayerSetup methods to access coordinate values and/or map layer setup data. Map authors control the security of this data from the Map Layer Properties dialog box in Autodesk MapGuide Author. If map
  • Autodesk 15606-011408-9300 | Developer Guide - Page 44
    There are some important points to remember about the busy state: I In general, most write methods and properties are affected by the busy state and return a -1 (busy) error code when called during a busy state. Most read methods and properties are not affected by the busy state. However, there are
  • Autodesk 15606-011408-9300 | Developer Guide - Page 45
    Controlling Map Refresh Operations You can ensure that Autodesk MapGuide Viewer will not enter a busy state by controlling when display refreshes occur. The first step is to remember that display refreshes always occur in the following instances: I When the autoRefresh flag is set to True with MGMap
  • Autodesk 15606-011408-9300 | Developer Guide - Page 46
    AutoRefresh Flag Caveats While autoRefresh is disabled, methods that would normally cause refreshes to occur do not, and the following types of operations may not work as expected: I Enumerating map features on dynamic layers after a pan or a zoom- If your application tries to return the number of
  • Autodesk 15606-011408-9300 | Developer Guide - Page 47
    and MGMap.setIntermediateUpdatesEnabled methods to control how frequently Autodesk MapGuide Viewer redraws a map. By default, maps are updated every 1.5 seconds, enabling the end user to progressively view a map as it is being rendered, rather than waiting until the entire map
  • Autodesk 15606-011408-9300 | Developer Guide - Page 48
    To get the most recently called method error code 1 Call the MGMap.getLastError method to get the MGError object. 2 Next call the MGError.getCode method to get the error code. For example: function checkErrorCode() { var map = getMap(); var code = map.getLastError().getCode(); alert("ERROR: " + code
  • Autodesk 15606-011408-9300 | Developer Guide - Page 49
    Working with Map Layers, Map Features, and Printing 4 This chapter shows you how to write code for common tasks your application can perform with the Autodesk MapGuide® Viewer API. Once your application can manipulate a map, you may want it to control other Autodesk MapGuide Viewer events, as
  • Autodesk 15606-011408-9300 | Developer Guide - Page 50
    Overview Throughout this chapter you will find simple JavaScript code samples that show you how to perform basic Autodesk MapGuide Viewer tasks in your application. You will learn how to work with map layers, features, and how to customize map printouts. Note that we refer to JavaScript code modules
  • Autodesk 15606-011408-9300 | Developer Guide - Page 51
    Next, the countLayers function calls the getMapLayersEx method, an Autodesk MapGuide Viewer API method that returns an MGCollection object containing all the layers defined in the map. The layer collection is assigned to the layers variable: var layers = map.getMapLayersEx(); Then it calls the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 52
    name to msg The first statement uses the item method to select a layer from the collection and assign it to a variable called layer. The second statement operates on the layer variable, first using the getName method to obtain the name of the layer represented by that variable, and then assigning
  • Autodesk 15606-011408-9300 | Developer Guide - Page 53
    Instead, we supplied the map object using the syntax required by each browser. Note If you support the Netscape browser, you must provide the name of the event observer as a second argument to addMapLayer. Linking Map Layers Using Autodesk MapGuide Author, you can set map layer attribute properties
  • Autodesk 15606-011408-9300 | Developer Guide - Page 54
    The function is named onViewChanging because it's triggered by the Autodesk MapGuide Viewer API event of the same name. Whenever an event is triggered, Autodesk MapGuide Viewer checks for a function whose name matches the event name. If the function is found, Autodesk MapGuide Viewer invokes it,
  • Autodesk 15606-011408-9300 | Developer Guide - Page 55
    Toggling Map Layer Visibility On and Off The layerToggle function toggles the visibility of a map layer that is specified when the function is invoked: function layerToggle(l_name) { var map = getMap(); var layer = map.getMapLayer(l_name); if (layer == null) alert("layer not found."); else { layer
  • Autodesk 15606-011408-9300 | Developer Guide - Page 56
    that the methods are concatenated; the first method, getSelection, operates on the map and returns a selection object, which is then passed to the second method, getNumObjects, for processing. If no map features are selected, an alert displays and the function terminates; otherwise, the selection is
  • Autodesk 15606-011408-9300 | Developer Guide - Page 57
    key + "\n"; The first statement uses the item method to select an object from the collection and assign it to a variable called obj. The second statement operates on the obj variable, first using the getKey method to obtain the key of the feature represented by that variable, and then assigning
  • Autodesk 15606-011408-9300 | Developer Guide - Page 58
    The following screen shows keys of the selected features displayed in the alert box. alert box displaying keys of selected features Getting Coordinates of a Selected Map Feature The doGetCoordinates function displays a dialog box showing the coordinates of a selected map feature: doGet Coordinates
  • Autodesk 15606-011408-9300 | Developer Guide - Page 59
    doGet Coordinates Function var cntVertices = map.createObject("MGCollection"); var res = obj.getVertices(vertices, cntVertices); if (res == 0) { alert("No access to coordinate information."); return; } msg = "Parcel:" + obj.getKey() + "\n"; msg = msg + "Coordinates in MCS unit\n"; for(var i = 0; i <
  • Autodesk 15606-011408-9300 | Developer Guide - Page 60
    method to select a vertex from the collection and assign it to a variable called pnt. The second statement operates on the pnt variable, using the getX and getY methods to get the vertex coordinates JavaScript alert box: alert(msg); 60 | Chapter 4 Working with Map Layers, Map Features, and Printing
  • Autodesk 15606-011408-9300 | Developer Guide - Page 61
    retrieve selected features and pass them to the variable selected. The first method, getSelection, returns a selection object, which is used by the second method, getMapObjectsEx. If you use getMapObjectsEx with a map layer, it returns an MGCollection object containing all features on the layer, but
  • Autodesk 15606-011408-9300 | Developer Guide - Page 62
    Before calling zoomSelected() After calling zoomSelected() Counting Map Features The showFeatureCount function counts the features on each map layer and adds that count to the legend: var legendSet; // Global variable, declared outside of function function showFeatureCount() { if (legendSet)
  • Autodesk 15606-011408-9300 | Developer Guide - Page 63
    The showFeatureCount function starts by checking the status of the global variable, legendSet. If legendSet is set to True, showFeatureCount terminates: if (legendSet) return; This keeps showFeatureCount from printing multiple messages to the legend if the user clicks the button more than once. Next
  • Autodesk 15606-011408-9300 | Developer Guide - Page 64
    such as the legend, scale bar, or North arrow. The API supports these user-interface features and also provides additional functionality, allowing you to out the page elements that will be sent to the printer. The second event, onEndLayout, is called after Autodesk MapGuide Viewer lays out the page
  • Autodesk 15606-011408-9300 | Developer Guide - Page 65
    much good if the ocean prints on top of the North arrow and hides it. To solve this problem, each page element is assigned a default print priority. A print priority is a positive floating-point number Default Print Priority 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 Working with Printing | 65
  • Autodesk 15606-011408-9300 | Developer Guide - Page 66
    The following example shows an onEndLayout event handler, written in JavaScript, that forces the title to be printed after the North arrow: function onEndLayout(layout, info) { // retrieve arrow and map elements var el_arrow = layout.getPageElement("mg_northarrow"); var el_map = layout.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 67
    Positioning Page Elements with Page Coordinate System Units Page element extents specified through the API are expressed in Page Coordinate System (PCS) units. The origin (0,0) of this system is located at the upper-left corner of the paper. Its exact location depends on the current left and top
  • Autodesk 15606-011408-9300 | Developer Guide - Page 68
    Adding Custom Page Elements You can add custom page elements to the printout. Currently, the API can only access symbols in the API symbol list. The API symbol list is a MWF or EMF file containing a small set of predefined symbols. However, additional symbols can be added to the list using Autodesk
  • Autodesk 15606-011408-9300 | Developer Guide - Page 69
    Handling Events 5 This chapter describes how to design your Autodesk MapGuide® Viewer application to handle Autodesk MapGuide® events. Handling events gives you more control over how your application responds to actions by users as they view maps. Once your application can handle Autodesk MapGuide
  • Autodesk 15606-011408-9300 | Developer Guide - Page 70
    and then call the event handler in response. Working with Event Handlers Netscape Navigator and Internet Explorer handle events differently, so if you want to support both browsers, you need to write code for both. Code examples that work for both are described in"Setting Up Event Handlers" on page
  • Autodesk 15606-011408-9300 | Developer Guide - Page 71
    Browser Differences The following table summarizes the basic differences between how Netscape Navigator and Internet Explorer handle events: Netscape Navigator Internet Explorer For Netscape Navigator, Autodesk MapGuide provides an observer applet that you embed in your application using the <
  • Autodesk 15606-011408-9300 | Developer Guide - Page 72
    is called MapGuideObserver6.class. I For Autodesk MapGuide Viewer, Java Edition, the applet is called MapGuideObserver6J.class. If your application is supporting both Autodesk MapGuide Viewer Plug-In and Autodesk MapGuide Viewer, Java Edition, you need to detect which Autodesk MapGuide Viewer is
  • Autodesk 15606-011408-9300 | Developer Guide - Page 73
    To use Autodesk MapGuide detection and event observer applet 1 Embed the observer applet in your Web page, assigning a specific name to it with the NAME attribute of the tag. If you are going to use both types of applets, you must give them different names and use the correct name in your
  • Autodesk 15606-011408-9300 | Developer Guide - Page 74
    Installing Plug-In and Java Editions Observer Applets (continued) // Autodesk MapGuide Viewer, Java Edition // with the observer object that handles selection // changed events. function onLoad() { if (navigator.appName() == "Netscape") getMap().setSelectionChangedObserver(document.obsJava); }
  • Autodesk 15606-011408-9300 | Developer Guide - Page 75
    If it finds such a function, it treats it as the event handler. Plug-In and ActiveX Control Event Handlers The following examples support event handling for both Netscape Navigator and Internet Explorer. VBScript Example This VBScript example is designed to handle the onDigitizedPoint event for both
  • Autodesk 15606-011408-9300 | Developer Guide - Page 76
    We named the event observer obs. To call this observer for Netscape Navigator, refer to the observer as document.obs, because in the Netscape object model the observer is an object of the document. Be sure to copy the Autodesk MapGuide Viewer Plug-In observer applet code MapGuideObserver6.class to
  • Autodesk 15606-011408-9300 | Developer Guide - Page 77
    , choose Help ➤ Contents ➤ Examples Advanced ➤ Event Handling in the Autodesk MapGuide Viewer API Help. This example implements an observer object that supports all of the observer interfaces by forwarding the events back to JavaScript functions that have identical semantics to the Autodesk MapGuide
  • Autodesk 15606-011408-9300 | Developer Guide - Page 78
    VBScript and JavaScript Example The following VBScript and JavaScript example shows an HTML page that handles the onSelectionChanged event for both Netscape and Microsoft browsers. This example forwards the event from your VBScript function to a shared JavaScript function that processes the event.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 79
    Page Setup Event Handler Example If you want your application to control settings from the Autodesk MapGuide Viewer Page Setup dialog box, you can write event handling code that responds to the onBeginLayout event. When onBeginLayout is triggered, it automatically passes two objects, the MGPageSetup
  • Autodesk 15606-011408-9300 | Developer Guide - Page 80
    3 Write the event handler. It goes in the HTML page (or the JavaScript .js file), just like any other JavaScript function. This function is executed automatically every time the onBeginLayout event fires. Note that the function takes an MGPageSetup object and an MGPrintInfo object as its parameters:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 81
    Print Event Handler Example If you want your application to change the title font, you can add a custom symbol, or control the position and size of any page element. To do this, you need to write event handling code that responds to the onEndLayout event. When onEndLayout is triggered, it
  • Autodesk 15606-011408-9300 | Developer Guide - Page 82
    3 Write the event handler. It goes in the HTML page (or the JavaScript .js file), just like any other JavaScript function. This function is executed automatically every time the onEndLayout event fires. Note that the function takes an MGPrintLayout object and an MGPrintInfo object as its parameters:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 83
    event observer for the onDigitizedCircle event. 2 Every time you call the method that triggers the event, pass in the name of your applet as the second parameter. For example, whenever you call digitizeCircle method in your applet, you must pass in your applet name (in this case, the keyword this
  • Autodesk 15606-011408-9300 | Developer Guide - Page 84
    84
  • Autodesk 15606-011408-9300 | Developer Guide - Page 85
    Using Reports to Query and Update Data Sources 6 Your Autodesk MapGuide® applications can include reports that enable users to display and modify database information associated with a map. This chapter explains how Autodesk MapGuide generates reports and shows you how to create report scripts
  • Autodesk 15606-011408-9300 | Developer Guide - Page 86
    of URL request passes key values of the selected map features. These key values are the keys that are defined in the data source. The second type of URL request passes a point feature and its location. Specifying the Report Script The report script contains the necessary code to connect to the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 87
    The Request Autodesk MapGuide® Author will use the report settings defined in the Map Window Properties dialog box to construct the URL that is sent to the server. For example, after all of the settings are specified, the URL code might look like this: http://www.myserver.com/reports/ report.cfm&
  • Autodesk 15606-011408-9300 | Developer Guide - Page 88
    runs in the background as a Windows® NT service. Both products work essentially the same way. You used to create that output. This developer's guide uses ColdFusion and ASP for its examples because supports both Microsoft® Internet Information Server® (IIS) and the Netscape® Web servers. ASP supports
  • Autodesk 15606-011408-9300 | Developer Guide - Page 89
    . A template uses the file extension .cfm to identify itself and let the Web server know that it should be passed to the ColdFusion service for processing. ColdFusion was designed to provide database connectivity to your Web pages. It is a full-fledged development environment that includes functions
  • Autodesk 15606-011408-9300 | Developer Guide - Page 90
    Setting Up the Query First we'll build the statement. If your map links to a table called Parcel_Data through a data source Assessor, will look like this: SELECT * FROM Parcel_Data The NAME attribute specifies the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 91
    Here's a listing of the complete CFM file called parcel_report.cfm: SELECT * FROM Parcel_Data Where Year_Built = '1963' ColdFusion Example Listing File Contents
  • Autodesk 15606-011408-9300 | Developer Guide - Page 92
    In most cases, you'll want to access your database resources through Autodesk MapGuide Viewer, by linking them to features and layers in the map. The next two examples show you how to do this. Querying and Displaying Data via the Map with ColdFusion Now that we've seen how ColdFusion works, let's
  • Autodesk 15606-011408-9300 | Developer Guide - Page 93
    Here are descriptions of how we used the options on the Reports tab: I Report-Specifies the report name as it appears in Autodesk MapGuide Viewer. Our report is Parcel Data (CF). I URL -Specifies the name and location of the report script, in this case parcel_report.cfm on www.yourserver.com. I Data
  • Autodesk 15606-011408-9300 | Developer Guide - Page 94
    Creating the Report Script Now let's create the ColdFusion template that will process the Autodesk MapGuide report. The following code listing is for the parcel_report.cfm file: ColdFusion Report Data ColdFusion-- ColdFusion query -->
  • Autodesk 15606-011408-9300 | Developer Guide - Page 95
    Creating an HTML Page to Display the Map The last step is to create an HTML page to display our map. The following is for the parcel_map.htm file: ColdFusion Example Querying and Displaying Data via the Map This example uses ColdFusion to
  • Autodesk 15606-011408-9300 | Developer Guide - Page 96
    Displaying the parcel data report in a new window Redirecting Report Output To avoid cluttering the desktop, let's generate the report in the current browser window, instead of displaying it in a new instance of the browser. Go back to the parcel_map.htm file and modify the embedded map code: <
  • Autodesk 15606-011408-9300 | Developer Guide - Page 97
    the current window. Displaying the parcel data report in the current window At first glance this appears to be a good solution, but it has some problems. Users might get confused about where they are. Worse yet, when they click the Back button, they will find that the map has been reloaded
  • Autodesk 15606-011408-9300 | Developer Guide - Page 98
    Start by creating a standard HTML file that defines a frameset. The frameset should display the map on the left and a blank page on the right: ColdFusion Report Data
  • Autodesk 15606-011408-9300 | Developer Guide - Page 99
    The following illustration shows the map and the report in two frames of the same window. Displaying the map and report in frames Users can now invoke as many reports as they want, without losing their place in the map or calling a new instance of the browser. Creating Report Scripts with ColdFusion
  • Autodesk 15606-011408-9300 | Developer Guide - Page 100
    the instructions remain in the frame to provide feedback. Note parent refers to the top-level frame and Right is the name we specified for our right-hand frame in parcel_frames.htm. Refer to third-party JavaScript documentation for more information on writing to frames and windows. The second
  • Autodesk 15606-011408-9300 | Developer Guide - Page 101
    This is a standard HTML form consisting of a single button named Parcel Report. By setting the value of ONCLICK to runReport, we specify that the function should be invoked each time a user clicks the button. Note A JavaScript function must appear above the JavaScript code that calls it. This keeps
  • Autodesk 15606-011408-9300 | Developer Guide - Page 102
    The following shows the application results if no map features have been selected. Displaying the map, a report frame, and a Parcel Report button Modifying a Database via the Map with ColdFusion This example shows how to create an application that lets users add points to a map from their browsers.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 103
    -Specifies whether the report is based on the keys of selected fea- tures, or on the coordinates of a point the user clicks. We chose the second option: Digitize a point and send point. I Prompt- Specifies the text to be displayed in a message box that prompts users to specify a point. If this field
  • Autodesk 15606-011408-9300 | Developer Guide - Page 104
    file, getpoint.cfm, creates a small browser window and then calls a second file, showform.cfm, passing along the coordinate values it received from Autodesk run. Be aware, however, that this strategy will get you into trouble if your file contains function calls or other multiple blocks.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 105
    loc variable to supply the URL. The last line shifts browser focus to the new window we just created. Now, let's look at the second CFM file, the showform.cfm file: Attribute Input
  • Autodesk 15606-011408-9300 | Developer Guide - Page 106
    The following illustration shows the showform.cfm form, as displayed in the window created by getpoint.cfm. Data entered in the showform.cfm form Specifying the lat/lon point 37.721,-121.943 by clicking the map and filling out the form as shown in the illustration will result in the following URL
  • Autodesk 15606-011408-9300 | Developer Guide - Page 107
    alert telling users to reload the map to see their changes. The second line closes the form window, leaving only the original map window. Creating that tells them to select a point, and then digitize the point. Another problem is that because our report isn't associated with a layer, users can add
  • Autodesk 15606-011408-9300 | Developer Guide - Page 108
    We can solve both of these problems by creating a custom menu item that takes the place of the report. We do so by selecting the map automatically. (That's why we have a JavaScript alert box telling the user to reload the map manually.) 108 | Chapter 6 Using Reports to Query and Update Data Sources
  • Autodesk 15606-011408-9300 | Developer Guide - Page 109
    To solve this problem and to avoid the need for the user to reload the map manually, you can use the Autodesk MapGuide Viewer API to access the Incident Log application. Instead of creating a report or custom menu item, add a button or
  • Autodesk 15606-011408-9300 | Developer Guide - Page 110
    text files on your Web site. Browser Capabilities Identifies the browser currently accessing the site and provides programmatic access to features the browser supports. Ad Rotator Controls the rotation of banner ads in a site. Content Linking Links separate Web pages together so that users can
  • Autodesk 15606-011408-9300 | Developer Guide - Page 111
    Events Used to Create a Report Script Event Description Session_OnStart Runs the first time a user accesses your application. Session_OnEnd Runs when a user's session times out or when a user quits your application. Application_OnStart Runs once, when the first page of your application is
  • Autodesk 15606-011408-9300 | Developer Guide - Page 112
    Specifying a Scripting Language ASP scripts are written in VBScript, a lightweight Visual Basic-like scripting language, or in JScript, the Microsoft version of JavaScript. ASP files should begin with a line telling ASP which language you're using (although a default of VBScript is assumed if the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 113
    The third line creates a variable that holds a SQL statement specifying the database records for houses built in 1963: SQLQuery = "SELECT * FROM Parcel_Data Where Year_Built = '1963'" The last line puts it all together, creating a Recordset object and assigning it to an object variable named RS.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 114
    This is a good start, but not quite what we want. To cycle through the records, we'll need to add some sort of looping code. That's what the two scripts are for. The beginning script contains a single line, which operates on the RS object. RS.EOF represents RS object's end-of-file property. In
  • Autodesk 15606-011408-9300 | Developer Guide - Page 115
    The following is the page as it appears in a browser. The HTML output Like the earlier ColdFusion example, this page is very simple, only hinting at the power of what you can do with ASP. And like the earlier example, this is not really an Autodesk MapGuide application. The database happens to be an
  • Autodesk 15606-011408-9300 | Developer Guide - Page 116
    Setting Up the Report in Autodesk MapGuide Author We'll start by specifying report information in Autodesk MapGuide Author. Our report will be called Parcel Data (ASP) and will access a server page whose URL is http://www.yourserver.com/asp/parcel_report.asp. The server page will display information
  • Autodesk 15606-011408-9300 | Developer Guide - Page 117
    When a user selects one or more features from the Assessment layer and runs the Parcel Data (ASP) report, Autodesk MapGuide constructs a URL that invokes parcel_report.asp and tells it to generate a report on the selected features, which are identified by their OBJ_KEY values. If the user selected a
  • Autodesk 15606-011408-9300 | Developer Guide - Page 118
    As with the previous example, the statement is selecting records from the Parcel_Data DSN. The difference is that the SQL statement now points to Request.Form, the ASP Request object's Form collection. The Request object is used by ASP to parse submitted data received from a client as part of a URL.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 119
    Seeing the Results We're ready to view parcel_map.htm in our Web browser, as shown in the following illustration. Now, users can generate a report on one or more map features by selecting the features, right-clicking and selecting View ➤ Reports from the popup menu, and then selecting Parcel Data (
  • Autodesk 15606-011408-9300 | Developer Guide - Page 120
    Redirecting Report Output To avoid cluttering the desktop, let's generate the report in the current browser window, instead of displaying it in a new instance of the browser. Go back to the parcel_map.htm file and modify the embedded map code:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 121
    At first glance this appears to be a good solution, but it has some problems. Users might get confused about where they are. Worse yet, when they click the Back button, they will find that the map has been reloaded
  • Autodesk 15606-011408-9300 | Developer Guide - Page 122
    Displaying the map and report in frames Adding a Button with the Viewer API An Autodesk MapGuide report is generated by right-clicking the map and then choosing View ➤ Reports from the popup menu. We'll create a Parcel Report button that will display the report. First we'll add the following
  • Autodesk 15606-011408-9300 | Developer Guide - Page 123
    , the instructions remain in the frame to provide feedback. Note parent refers to the top-level frame and Right is the name we specified for our right-hand frame in parcel_frames.htm. Refer to a third-party JavaScript manual for more information on writing to frames and windows. The second statement
  • Autodesk 15606-011408-9300 | Developer Guide - Page 124
    This the final text of parcel_map.htm, as well as the finished application: parcel_map.htm ASP Example // function #1 function getMap() { if (navigator.appName == "Netscape") return parent.Left.document.map; else return parent.Left.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 125
    Displaying the map, a report frame, and a Parcel Report button Modifying a Database via the Map with ASP Users can add points to a map from their browsers. The added points are then stored in a database on the server and are visible to anyone viewing the map. The example shows a hypothetical
  • Autodesk 15606-011408-9300 | Developer Guide - Page 126
    Type -Specifies whether the report is based on the keys of selected features, or on the coordinates of a point the user clicks. We chose the second option: Digitize a point and send point. I Prompt-Specifies the text to be displayed in a message box prompting users to specify a point. If this field
  • Autodesk 15606-011408-9300 | Developer Guide - Page 127
    file, getpoint.asp, creates a small browser window and then calls a second file, showform.asp, passing along the coordinate values it received from Autodesk run. Be aware, however, that this strategy will get you into trouble if your file contains function calls or other multiple blocks.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 128
    the loc variable to supply the URL. The last line shifts browser focus to the new window we just created. Now, let's look at the second ASP file, the showform.asp file: Attribute Input
  • Autodesk 15606-011408-9300 | Developer Guide - Page 129
    In short, an HTML form collects data from the user and sends that data to a program in the form of a URL. The form in showform.asp calls yet another ASP file, insert.asp, passing it the following parameters: I The latitude value obtained from the ASP variable ; this
  • Autodesk 15606-011408-9300 | Developer Guide - Page 130
    Specifying the lat/lon point 37.721,-121.943 by clicking the map and filling out the form as shown in the illustration will result in the following URL being constructed and passed to the insert.asp file: insert.asp?rpt_lat=37.721&rpt_lon=121.943&rpt_info=A+cat+was+stolen&rpt_by=J+Appell Now we'll
  • Autodesk 15606-011408-9300 | Developer Guide - Page 131
    documentation for more information. In the element, the first line displays an alert telling users to reload the map to see their changes. The second line closes the form window, leaving only the original map window. Creating an HTML Page to Display the Map The last step is to create
  • Autodesk 15606-011408-9300 | Developer Guide - Page 132
    isn't associated with a layer, users can add items to the Incidents map layer even when that layer isn't visible. We can solve both of these problems by creating a custom menu item that takes the place of the report. Select the options, as shown in the following illustration, on the Popup Menu
  • Autodesk 15606-011408-9300 | Developer Guide - Page 133
    the map automatically. (That's why we have a JavaScript alert box telling the user to reload the map manually.) To solve this problem and to avoid having the need for the user to reload the map manually, you can use the Autodesk MapGuide Viewer API to access the Incident Log application. Instead of
  • Autodesk 15606-011408-9300 | Developer Guide - Page 134
    134
  • Autodesk 15606-011408-9300 | Developer Guide - Page 135
    Applications This chapter demonstrates various features of the Autodesk MapGuide® Viewer API by describing and including source code for several applications. 7 I Overview I Custom redlining application I Municipal application I Facility management application I DWG filtering application I SDF
  • Autodesk 15606-011408-9300 | Developer Guide - Page 136
    Overview This chapter provides examples of how you might use the Autodesk MapGuide Viewer API to create real-world applications. Be sure to also visit the Autodesk MapGuide Web site at www.autodesk.com/mapguide for additional information about Autodesk MapGuide development, including demo
  • Autodesk 15606-011408-9300 | Developer Guide - Page 137
    4 Use the MGMap.saveMWF method to save the map file to an MWF on the user's machine or a network server. MGMap.saveMWF is not available for Autodesk MapGuide Viewer, Java Edition. Note For information about adding and deleting features from the data source itself (such as an SDF file), rather than
  • Autodesk 15606-011408-9300 | Developer Guide - Page 138
    The Add/Update Polygon button calls a JavaScript function that lets the user draw a polygon by digitizing points on the map. The function first checks to see if there's a value in the Polygon Name check box. If there is a value, the function calls either the digitizePolygon or digitizePolygonEx
  • Autodesk 15606-011408-9300 | Developer Guide - Page 139
    onDigitizedPolygon Function (continued) var obj = layer.getMapObject(formText); if (obj == null) var obj = layer.createMapObject(formText, formText, ""); // create MGCollection that holds user-specified polygon vertices var user_vertices = map.createObject("mgcollection"); user_vertices.add(
  • Autodesk 15606-011408-9300 | Developer Guide - Page 140
    layers on and off and select them. At the right of the window the application includes Incident Monitor, where users are notified if there are problems with the water distribution system, and Layer Control, which allows you to turn off the incident layer, turn off all vector layers at the same
  • Autodesk 15606-011408-9300 | Developer Guide - Page 141
    Municipal Application Example Code Following is the source code for the controls. Additional comments have been added to the code to give you a better idea of how the scripting works. To view the source code for the other frames in this application, go to the application online at www.autodesk.com/
  • Autodesk 15606-011408-9300 | Developer Guide - Page 142
    Municipal Application Example Code (continued Function: notify() // Description: Turns on Incident Monitor by calling // CreateInWindow() function, below // Arguments: none // Returns: nothing function notify() { // Call function CreateInWindow(); } Function: CreateInWindow() // Description:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 143
    don't do the stuff above; // instead, display alert else alert("The Autodesk MapGuide Viewer is busy. Please try again in a few seconds."); } // Function: vector(type) // Description: Turns vector layers on or off (called by // ON/OFF buttons, under Layer Control: Vector Layers) // Arguments
  • Autodesk 15606-011408-9300 | Developer Guide - Page 144
    = map.getMapLayer("Highways"); var mapLayer9 = map.getMapLayer("Major Roads"); var mapLayer10 = map.getMapLayer("Minor Roads"); var mapLayer11 = map.getMapLayer("Water Service Acct."); var mapLayer12 = map.getMapLayer("Water - 3 inch Valves"); var mapLayer13 = map.getMapLayer("Water - Point of
  • Autodesk 15606-011408-9300 | Developer Guide - Page 145
    The Autodesk MapGuide Viewer is busy. Please try again in a few seconds."); // End the function } // Function: raster(type) // Description: called // with 'On', make mapRastLayer visible if (CurrentScale < 20000 && type == 'On') { mapRastLayer.setVisibility(true); mapRastLayer.setRebuild(true
  • Autodesk 15606-011408-9300 | Developer Guide - Page 146
    Example Code (continued) // instead, display alert else alert("The Autodesk MapGuide Viewer is busy. Please try again in a few seconds."); } Function: digit() // Description: Lets users create report data for a specified // point. (called by the 'Digitize Incident' button, under // 'Incident
  • Autodesk 15606-011408-9300 | Developer Guide - Page 147
    alert if (map.isBusy() == false) map.digitizePoint(); else alert("The Autodesk MapGuide Viewer is busy. Please try again in a few seconds."); } } // Function: reporter() // Description: Generates report data for selected map features // (called by 'Reporter' button, under 'Incident Entry
  • Autodesk 15606-011408-9300 | Developer Guide - Page 148
    Municipal Application Example Code (continued) } // Function: showIncidents() // Description: Constructs SQL 'Where' statement requesting map // features (request is based on user's selection from 'Date' and // 'Status' drop-downs, under 'Incident Entry & Reporting'); sends // the SQL
  • Autodesk 15606-011408-9300 | Developer Guide - Page 149
    Municipal Application Example Code (continued) if (temp == 'showAll') { var whereClause1 = "Status is not null"; } // If user selected any other drop-down item, assign // whereClause1 the string "Status=" plus the list item name // (i.e., "Status='New'" or "Status='Old'") else { var whereClause1 = "
  • Autodesk 15606-011408-9300 | Developer Guide - Page 150
    Page Setup dialog; // otherwise display alert if (map.isBusy() == false) map.pageSetupDlg(); else alert("The Autodesk MapGuide Viewer is busy. Please try again in a few seconds."); } Function printMap() 150 | Chapter 7 Applications
  • Autodesk 15606-011408-9300 | Developer Guide - Page 151
    display alert if (map.isBusy() == false) map.printDlg(); else alert("The Autodesk MapGuide Viewer is busy. Please try again in a few seconds."); } //-->
  • Autodesk 15606-011408-9300 | Developer Guide - Page 152
    Municipal Application Example Code (continued)
  • Autodesk 15606-011408-9300 | Developer Guide - Page 153
    Municipal Application Example Code (continued) WIDTH=30 HEIGHT=21 BORDER=0>
  • Autodesk 15606-011408-9300 | Developer Guide - Page 154
    Municipal Application Example Code (continued)
  • Autodesk 15606-011408-9300 | Developer Guide - Page 155
    Municipal Application Example Code (continued)
  • Autodesk 15606-011408-9300 | Developer Guide - Page 156
    Facility Management Application The Facility Management application demonstrates how you can create a Web-based facility management application to manage and maintain various facilities. Its layout is similar to the Municipal Application, but it has more advanced navigation controls at the right of
  • Autodesk 15606-011408-9300 | Developer Guide - Page 157
    Facilities Management Application Example Code Following is the source code for the controls. Additional comments have been added to the code to give you a better idea of how the scripting works. To view the source code for the other frames in this application, go to the Demos and Customers section
  • Autodesk 15606-011408-9300 | Developer Guide - Page 158
    Facilities Management Application Example Code (continued) else map = null; return map; } // none if other browser //return map object // Function: Pan(direction) // Description: pans in the specified direction // Arguments: direction // Return: nothing function Pan(direction) { //
  • Autodesk 15606-011408-9300 | Developer Guide - Page 159
    Facilities Management Application Example Code (continued) xyPt.setY(xyPt.getY() + delta) } if (direction == 'Ur') { xyPt.setX(xyPt.getX() + delta) xyPt.setY(xyPt.getY() + delta) } if (direction == 'Down') { xyPt.setY(xyPt.getY() - delta) } if (direction == 'Ld') { xyPt.setX(xyPt.getX() - delta)
  • Autodesk 15606-011408-9300 | Developer Guide - Page 160
    'Scale') map.zoomScaleDlg(); else map.zoomWidthDlg(); } else alert("The Autodesk MapGuide Viewer is busy ... please\n try again in a few seconds"); } + Function: selMapObj() + + Description: select by object, uses the Select Map Objects dialog + + Arguments: none + + Return: none
  • Autodesk 15606-011408-9300 | Developer Guide - Page 161
    Facilities Management Application Example Code (continued) + Function: ObjSelChanged() + + Description: on change of selection, highlight room selected + + Arguments: none + + Return: none + function ObjSelChanged() { // Get MGMap object var map = getMap(); if (map.isBusy() == false){
  • Autodesk 15606-011408-9300 | Developer Guide - Page 162
    Facilities Management Application Example Code (continued) if (selValue[i].selected){ var temp = selValue[i].value; } } if (temp == 'showAll'){ var whereClause = "Space_Status is not null"; } else{ var whereClause = "Space_Status='"+temp+"'"; } var mapLayer = map.getMapLayer("Offices"); mapLayer.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 163
    Facilities Management Application Example Code (continued) else{ SearchWindow = window.open("Search.cfm?FirstName=" +FirstName+"&LastName="+LastName+ "&Room="+RoomSelected, "SearchWindow","toolbar=no,width=350,height=205,directories=no, status=no,scrollbars=no,resize=yes,menubar=no") } } //-->
  • Autodesk 15606-011408-9300 | Developer Guide - Page 164
    DWG Filtering Application This example demonstrates filtering Autodesk DWG layers and selecting map features. Autodesk DWG is a worldwide standard across vertical industries, such as architectural design, and facilities planning and maintenance. For a working version of this application, choose Help
  • Autodesk 15606-011408-9300 | Developer Guide - Page 165
    Understanding Layers in Autodesk MapGuide When working with DWG data especially, it is important to understand the difference between Autodesk DWG layers, Autodesk MapGuide map layers, and Autodesk DWG map layers. These are not the same and are defined as follows: Layer Type Autodesk DWG layer
  • Autodesk 15606-011408-9300 | Developer Guide - Page 166
    DWG Filtering Application Example Code This example illustrates some basic tasks an application can perform when working with DWG data. It primarily focuses on setting DWG filters and getting DWG data, but it can easily be modified to change other Autodesk MapGuide map layer properties, such as the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 167
    7 Set the layer filter from the selected filter list using the dwgMapLayerDataSource.setLayerFilter(filterList) method. 8 Refresh the map using the map.refresh method. DWG Filtering Application selChanged Example Code // Selection Changed Function // Called whenever items are selected or deselected
  • Autodesk 15606-011408-9300 | Developer Guide - Page 168
    Show Properties Function (showProperties) The following are excerpts from the showProperties() function. This function gets and displays properties of selected map features in a table in the output frame of the Web page, including DWG properties associated with the DWG map layer. The basic
  • Autodesk 15606-011408-9300 | Developer Guide - Page 169
    DWG Filtering Application showProperties Example Code (continued) parent.outputframe.document.write (""); parent.outputframe.document.write ("Map Feature"); parent.outputframe.document.write (""); ... parent.outputframe.document.write (""); // Get the map and selected features
  • Autodesk 15606-011408-9300 | Developer Guide - Page 170
    DWG Filtering Application showProperties Example Code (continued) var layerFilter = dwgMapLayerDataSource.getLayerFilter(); if (layerFilter == "") parent.outputframe.document.write ("No filter applied"); else parent.outputframe.document.write (layerFilter); parent.outputframe.document.write ("
  • Autodesk 15606-011408-9300 | Developer Guide - Page 171
    Basic (VB) examples. The SDF Component Toolkit is a set of COM objects for reading and writing Spatial Data Files (SDFs), as well as their supporting Spatial Index Files (SIFs) and Key Index Files (KIFs). The spatial data displayed in Autodesk MapGuide maps (map features such as roads, countries
  • Autodesk 15606-011408-9300 | Developer Guide - Page 172
    This example is called "Points of Interest." It uses Active Server Pages (ASP) and SDF Component Toolkit commands to allow users to add points of interest to the map, which will also be added to the corresponding SDF data source. SDF Component Toolkit Points of Interest application Notice that the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 173
    The main page is called maps_poi.htm. It contains the following code, which sets up the frames: maps_poi.htm Example Code Points of Interest Sample
  • Autodesk 15606-011408-9300 | Developer Guide - Page 174
    map.htm Example Code (continued) bVer = parseInt(navigator.appVersion); if (bName == "Netscape" && bVer >= 4) ver = "n4"; else if (bName == "Microsoft Internet Explorer" && bVer >= 4) ver = "e4"; else ver = "other"; // ...if Netscape, embed event observer if (ver == "n4") { document.write("
  • Autodesk 15606-011408-9300 | Developer Guide - Page 175
    map.htm Example Code (continued) <
  • Autodesk 15606-011408-9300 | Developer Guide - Page 176
    poi.asp Example Code (continued) // Now, use the SDF Component Toolkit commands to drive the controls. // This code is all wrapped within an if statement that verifies // whether a valid command (add, find, or remove) has been issued // before it creates an instance of the SDF Component Toolkit. if
  • Autodesk 15606-011408-9300 | Developer Guide - Page 177
    , updating map."; } else msgText = "Point not found."; } } //If it's the Find command, open the SDF as read-only by setting //the second parameter to 1 (sdfOpenRead) instead of 2 //(sdfOpenUpdate). else if (op == "Find") { var sdfObject = null; sdfToolKit.Open("c:\\sdf\\poi.sdf", 1, true); sdfObject
  • Autodesk 15606-011408-9300 | Developer Guide - Page 178
    poi.asp Example Code (continued) zoomToLon = sdfPoint.X; zoomToLat = sdfPoint.Y; clearVars(); actionOp = "ZoomToPoint"; // Zooms to the point on the map msgText = "Zooming to point."; } else msgText = "Point not found."; } sdfToolKit.Close(); } else msgText = "A name must be specified." } else if (
  • Autodesk 15606-011408-9300 | Developer Guide - Page 179
    poi.asp Example Code (continued) SIZE="20" maxlength="255" ID="fp1"> Latitude Longitude
  • Autodesk 15606-011408-9300 | Developer Guide - Page 180
    poi.asp Example Code (continued) function getMap() { if (ver == "n4") return parent.mapFrame.document.map; else return parent.mapFrame.map; } // Following is the function called by the Digitize button. If the // browser is Navigator, it will send the onDigitizedPoint event to // the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 181
    poi.asp Example Code (continued) Response.Write(""); } %> Once you understand the object hierarchy, using the SDF Component Toolkit is very straightforward. This example used ASP, but you can apply similar techniques using ColdFusion or another language. Please go to the
  • Autodesk 15606-011408-9300 | Developer Guide - Page 182
    ConvertSDF Example Code (continued) Caption Height Left TabIndex Top = "Convert" = 288 = 4440 =6 = 960 Width = 1212 End Begin VB.CommandButton btnBrowseTxt Caption = "Browse" Height = 288 Left = 4440 TabIndex =5 Top = 120 Width = 1212 End Begin VB.TextBox txtTxtName Height =
  • Autodesk 15606-011408-9300 | Developer Guide - Page 183
    ConvertSDF Example Code (continued) End Begin VB.CommandButton btnBrowseSdf Caption = "Browse" Height = 288 Left = 4440 TabIndex =1 Top = 480 Width = 1212 End Begin RichTextLib.RichTextBox txtMsg Height = 2292 Left = 120 TabIndex =0 Top = 960 Width = 4212 _ExtentX = 7430
  • Autodesk 15606-011408-9300 | Developer Guide - Page 184
    ConvertSDF Example Code (continued) ErrHandler: 'Cancel was selected 'Just exit after resetting errhandler On Error GoTo 0 End Sub Private Sub btnBrowseTxt_Click() On Error GoTo ErrHandler cdOpen.Filter = "Text Files (*.TXT)| *.TXT" cdOpen.FilterIndex = 1 cdOpen.DialogTitle = "Open SDF File" 'Show
  • Autodesk 15606-011408-9300 | Developer Guide - Page 185
    ConvertSDF Example Code (continued) oTlkt.BeginUpdate j=0 'Read from txt file till eof Do While Not EOF(1) 'Get the feature data Line Input #1, strObjType Line Input #1, strKey Line Input #1, strName Line Input #1, strUrl Line Input #1, strCnt 'Key 'Name 'Url 'Vertex count 'Read the geometry For i
  • Autodesk 15606-011408-9300 | Developer Guide - Page 186
    ConvertSDF Example Code (continued) Close #1 ShowMessage txtTxtName.Text & " converted to " & txtSdfName.Text ShowMessage "Total features converted: " & j Exit Sub ErrHandler: 'Display the error number/message MsgBox Err.Number & " : " & Err.Description 'Reset the handler before exiting On Error
  • Autodesk 15606-011408-9300 | Developer Guide - Page 187
    ConvertSDF Example Code (continued) objFound = Not (oObj Is Nothing) If Not (oObj Is Nothing) Then ShowMessage "Following feature is deleted" ShowMessage "Feature: " & i & " " & GetObjectTypeString(oObj.Type) ShowMessage " Key : " & oObj.Key ShowMessage " Name: " & oObj.Name ShowMessage " Url : " &
  • Autodesk 15606-011408-9300 | Developer Guide - Page 188
    ConvertSDF Example Code (continued) GetObjectTypeString = "POLYGON" Case sdfPolylineObject: GetObjectTypeString = "POLYLINE" Case sdfPolyPolylineObject: GetObjectTypeString = "POLYPOLYLINE" Case sdfPolyPolygonObject: GetObjectTypeString = "POLYPOLYGON" End Select End Function Getting SDF File
  • Autodesk 15606-011408-9300 | Developer Guide - Page 189
    SDFInfo Example Code (continued) TabIndex =6 Top = 1800 Width = 1212 End Begin VB.CommandButton btnSrchSpat Caption = "Spatial Search" Height = 288 Left = 4440 TabIndex =5 Top = 1440 Width = 1212 End Begin VB.CommandButton btnSrchSeq Caption = "Seq Search" Height = 288
  • Autodesk 15606-011408-9300 | Developer Guide - Page 190
    SDFInfo Example Code (continued) Height = 288 Left = 4440 TabIndex =1 Top = 120 Width = 1212 End Begin RichTextLib.RichTextBox txtMsg Height = 2652 Left = 120 TabIndex =0 Top = 600 Width = 4212 _ExtentX = 7430 _ExtentY = 4678 _Version = 393217 Enabled = -1 'True
  • Autodesk 15606-011408-9300 | Developer Guide - Page 191
    SDFInfo Example Code (continued) Private Sub btnExit_Click() End End Sub Private Sub btnShowInfo_Click() 'Check if there is a file name in edit box If txtSdfName.Text = "" Then ShowMessage ("Select an SDF file first!") Exit Sub End If Dim oTlkt As New SdfToolkit Dim oBox As SdfBoundingBox Dim strMsg
  • Autodesk 15606-011408-9300 | Developer Guide - Page 192
    SDFInfo Example Code (continued) 'Get total count of features strMsg = oTlkt.TotalObjects ShowMessage "Total features: " & strMsg 'Check for feature classes present in this sdf ShowMessage "Contains Points: " & oTlkt.ContainsObjectClass(sdfPointClass) ShowMessage "Contains Polylines: " & oTlkt.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 193
    SDFInfo Example Code (continued) On Error GoTo ErrHandler 'Open the sdf file in read-only mode oTlkt.Open txtSdfName.Text, sdfOpenRead, True 'Begin spatial search for polylines oTlkt.BeginKeyIndexSearch (Key) 'Get first feature Set oObj = oTlkt.SearchToNextObject() objFound = Not (oObj Is Nothing)
  • Autodesk 15606-011408-9300 | Developer Guide - Page 194
    SDFInfo Example Code (continued) Dim oTlkt As New SdfToolkit Dim oObj As SdfObject Dim strMsg As String Dim i As Long On Error GoTo ErrHandler 'Open the sdf file in read-only mode oTlkt.Open txtSdfName.Text, sdfOpenRead, True 'Begin sequential search oTlkt.BeginSequentialSearch 'Get first feature
  • Autodesk 15606-011408-9300 | Developer Guide - Page 195
    SDFInfo Example Code (continued) Dim oTlkt As New SdfToolkit Dim oBox As SdfBoundingBox Dim oObj As SdfObject Dim strMsg As String Dim i As Long On Error GoTo ErrHandler 'Open the sdf file in read-only mode oTlkt.Open txtSdfName.Text, sdfOpenRead, True 'Get the SDF extents Set oBox = oTlkt.
  • Autodesk 15606-011408-9300 | Developer Guide - Page 196
    SDFInfo Example Code (continued) txtMsg.Text = txtMsg.Text & Msg & vbCrLf End Sub Function GetObjectTypeString(ObjType As SdfObjectType) As String Select Case ObjType Case sdfPointObject: GetObjectTypeString = "POINT" Case sdfPolygonObject: GetObjectTypeString = "POLYGON" Case sdfPolylineObject:
  • Autodesk 15606-011408-9300 | Developer Guide - Page 197
    CopySDF Example Code (continued) End Begin VB.CommandButton btnBrowseInSdf Caption = "Browse" Height = 288 Left = 4440 TabIndex =5 Top = 120 Width = 1212 End Begin VB.TextBox sdfInName Height = 288 Left = 120 TabIndex =4 Text = "d:\work\mapguide\redline.sdf" Top = 120
  • Autodesk 15606-011408-9300 | Developer Guide - Page 198
    CopySDF Example Code (continued) Top = 480 Width = 1212 End Begin RichTextLib.RichTextBox txtMsg Height = 2292 Left = 120 TabIndex =0 Top = 960 Width = 4212 _ExtentX = 7430 _ExtentY = 4043 _Version = 393217 Enabled = -1 'True ReadOnly = -1 'True ScrollBars =2 TextRTF =
  • Autodesk 15606-011408-9300 | Developer Guide - Page 199
    CopySDF Example Code (continued) End Sub Private Sub btnBrowseOutSdf_Click() On Error GoTo ErrHandler cdOpen.Filter = "SDF Files (*.SDF)| *.SDF" cdOpen.FilterIndex = 1 cdOpen.DialogTitle = "Save SDF File" 'Show the open dialog box cdOpen.ShowSave sdfOutName.Text = cdOpen.FileName ErrHandler: 'Cancel
  • Autodesk 15606-011408-9300 | Developer Guide - Page 200
    CopySDF Example Code (continued) yMin = oBox.MinY + Abs((Abs(oBox.MaxY) - Abs(oBox.MinY)) / 3) yMax = oBox.MaxY - Abs((Abs(oBox.MaxY) - Abs(oBox.MinY)) / 3) oBox.SetExtent xMin, yMin, xMax, yMax 'Start searching from insdf and writing to outsdf oTlktIn.BeginSpatialIndexSearch sdfAllObjectClasses,
  • Autodesk 15606-011408-9300 | Developer Guide - Page 201
    CopySDF Example Code (continued) Function GetObjectTypeString(ObjType As SdfObjectType) As String Select Case ObjType Case sdfPointObject: GetObjectTypeString = "POINT" Case sdfPolygonObject: GetObjectTypeString = "POLYGON" Case sdfPolylineObject: GetObjectTypeString = "POLYLINE" Case
  • Autodesk 15606-011408-9300 | Developer Guide - Page 202
    202
  • Autodesk 15606-011408-9300 | Developer Guide - Page 203
    -In Autodesk MapGuide Viewer, Java Edition. See Java Edition Autodesk MapGuide Viewer. See Viewer Autodesk MapGuide Web site 13 autoRefresh 46 B bitmap support 8 browsers supported 9, 18 busy state about 43 detecting change in 46 handling 43 C CFM files 89, 92, 102 checking argument types 48 Index
  • Autodesk 15606-011408-9300 | Developer Guide - Page 204
    ColdFusion 10 about 89 and Autodesk MapGuide LiteView 26 creating reports with 85, 86, 89, 142, 146, 149 defined 88 listing database contents with 89, 92, 102 querying data 14, 85 template files 89, 92, 102 updating data 14, 85 coordinates of map features 58 counting map features 62 map layers 50
  • Autodesk 15606-011408-9300 | Developer Guide - Page 205
    29 Plug-In 28 intermediate updates 8, 47 Internet Explorer and observer objects 36 embedding a map 22 event handling 71 event observers in 70 JavaScript support in 32, 36 map access 32 invoking radius mode 61 J Java 10 applet wrapper for Java Edition 38 application as wrapper for Java Edition 38
  • Autodesk 15606-011408-9300 | Developer Guide - Page 206
    page elements 67 adding 68 positioning for printing 67 page setup events 79 PCS. See page coordinate system Perl 26 platform requirements 9, 18 platform support changes 9 Plug-In 11 applet for communication 40 displaying a map in 20 embedding a map 22 installing on client machine 28 linking to a map
  • Autodesk 15606-011408-9300 | Developer Guide - Page 207
    parameters, reports and 93, 104, 117, 126 V VBScript 10, 112 defined 70 event handler example 75, 78 setting up event handlers 70, 71, 75 supported configurations 19 using for reports in Active Server Pages 109 See also Visual Basic Viewer about 11 ActiveX Control 11, 20 creating an application 15
  • Autodesk 15606-011408-9300 | Developer Guide - Page 208
    visibility of DWG layers 164 of map layers 55 Visual Basic 10 SDF Component Toolkit example 181, 188, 196 stand-alone Windows applications 19 W Windows supported configurations 19 X XML 10 Z zooming 61 208 | Index
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208

15306-010000-5060
October 2001
Autodesk MapGuide
®
Release 6
Developer’s Guide