background image

15306-010000-5060

October 2001

Autodesk MapGuide

®

 Release 6

Developer’s Guide

Summary of Contents for 15606-011408-9300 - MAP R6.3 UPG

Page 1: ...15306 010000 5060 October 2001 Autodesk MapGuide Release 6 Developer s Guide ...

Page 2: ... Animation Player Animation Pro Player A Studio in Every Computer ATLAST Auto Architect AutoCAD Architectural Desktop AutoCAD Architectural Desktop Learning Assistance AutoCAD Learning Assistance AutoCAD LT Learning Assistance AutoCAD Simulator AutoCAD SQL Extension AutoCAD SQL Interface Autodesk Animator Clips Autodesk Animator Theatre Autodesk Device Interface Autodesk Inventor Autodesk PhotoEDI...

Page 3: ...sk MapGuide Viewer API Help 13 Autodesk MapGuide Web Site 13 What Is an Autodesk MapGuide Viewer API Application 13 Viewing Maps 14 Querying and Updating Data 14 Creating an Autodesk MapGuide Viewer API Application 15 Chapter 2 Displaying Maps 17 Overview 18 Map Display for ActiveX Control and Plug In 20 Linking to a Map 20 Embedding a Map 22 Map Display for the Java Edition 24 Map Display for Aut...

Page 4: ...ting Map Layers 50 Listing Map Layers 51 Adding a Map Layer 53 Linking Map Layers 53 Toggling Map Layer Visibility On and Off 55 Working with Map Features 56 Getting Keys of Selected Map Features 56 Getting Coordinates of a Selected Map Feature 58 Invoking Select Radius Mode 61 Zooming In on Selected Features 61 Counting Map Features 62 Working with Printing 64 Setting the Print Priority 65 Enabli...

Page 5: ...s and Events 110 Listing File Contents with ASP 111 Querying and Displaying Data via the Map with ASP 115 Modifying a Database via the Map with ASP 125 Chapter 7 Applications 135 Overview 136 Custom Redlining Application 136 Redlining Example Code 137 Municipal Application 140 Municipal Application Example Code 141 Facility Management Application 156 Facilities Management Application Example Code ...

Page 6: ...vi ...

Page 7: ...is a complete guide to Autodesk MapGuide customization and development features This chapter introduces Autodesk MapGuide application development and describes how to use Autodesk MapGuide Viewer API to develop such applications What s new in Release 6 Before you begin About the Autodesk MapGuide Viewer API What is an Autodesk MapGuide Viewer API application Creating an Autodesk MapGuide Viewer AP...

Page 8: ...GDwgDataSources were added Two MGMapLayerSetup methods getDataFile and setDataFile methods and one property DataFile were also changed to support DWG data sources See DWG Filtering Application on page 164 for an example of working with DWG data sources Enhanced Support for Map Redraw Operations Two new MGMap methods getIntermediateUpdatesEnabled and setIntermediateUpdatesEnabled and a new property...

Page 9: ...b applications Equally important you need to know who your users are and what they need as well as how to deliver help about your applications Familiarity with Autodesk MapGuide You need to be very familiar with Autodesk MapGuide In particular you should read the first few chapters of the Autodesk MapGuide User s Guide to make sure you understand the product especially emphasizing the following se...

Page 10: ...de scripts that dynam ically update SDF files posted on an Autodesk MapGuide Server For more information about using this toolkit see SDF Component Toolkit Appli cations on page 171 and refer to the SDF Component Toolkit Help Use the Autodesk MapGuide Viewer API to process redlining data and update your data sources For more information about working with redlining data see Custom Redlining Applic...

Page 11: ...e different types Autodesk MapGuide Viewer ActiveX Control Autodesk MapGuide Viewer Plug In and Autodesk MapGuide Viewer Java Edition These Viewer types are sometimes referred to as Viewer versions within the Help and the documentation Be careful to not confuse this usage with Autodesk MapGuide release versions Each Autodesk MapGuide Viewer type exposes a programming interface that you can use to ...

Page 12: ...eate very powerful applications In this context an Autodesk MapGuide Viewer application is a Web page containing one or more maps each of which is displayed in a separate instance of the Autodesk MapGuide Viewer The Web page can also have frames buttons controls graphics and so on for querying and controlling the map and its data In most cases you will write your application code within one or mor...

Page 13: ...Web site at www autodesk com mapguide The site provides many examples of applications developed with Autodesk MapGuide both demo applications and real customer sites You will also find links to resources such as Autodesk MapGuide Viewer API Help API exam ples general product documentation and discussion groups What Is an Autodesk MapGuide Viewer API Application An Autodesk MapGuide Viewer API appl...

Page 14: ...ally you can use these scripts to enable the user to update the data For example you could display the date of last service in a text field where the technician in the field could update it Your script would then take the technician 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 abou...

Page 15: ...k For more information Simple Applications Display maps by either linking to or embedding them in an HTML page See Chapter 2 Displaying Maps Programmatically access and manipulate maps map layers and map features See Chapter 3 Accessing Maps and Chapter 4 Work ing with Map Layers Map Fea tures and Printing Advanced Applications Respond to Autodesk MapGuide Viewer events See Chapter 5 Handling Even...

Page 16: ...16 ...

Page 17: ... MapGuide Viewer Plug In or Autodesk MapGuide Viewer Java Edition Once your application can display a map you can access the map programmatically as described in Chapter 3 Accessing Maps Overview Map display for ActiveX Control and Plug In Map display for the Java Edition Map display for Autodesk MapGuide LiteView Installing Viewers on client machines ...

Page 18: ... Autodesk MapGuide Viewer or if they do not need query or more advanced function ality provided by Autodesk MapGuide Viewers they can use Autodesk MapGuide LiteView instead For more information about this viewing solu tion see Map Display for Autodesk MapGuide LiteView on page 26 The Autodesk MapGuide Viewers you choose to support depend on the browser operating environment of your users The progr...

Page 19: ...k MapGuide Viewer Java Edition HTML JScript JavaScript Java Netscape Navigator Autodesk MapGuide Viewer Plug In HTML JavaScript Autodesk MapGuide Viewer Java Edition HTML JavaScript Java None stand alone application Autodesk MapGuide Viewer ActiveX Control Visual Basic Mac OS Internet Explorer Autodesk MapGuide Viewer Java Edition HTML Java Solaris Netscape Navigator Autodesk MapGuide Viewer Java ...

Page 20: ...play a map by creating a link to the map from an HTML page The when the user clicks the link the map displays full screen Note that the browser displays the map by itself not as part of an HTML page Create the link just like any other link in HTML using the A tag with the HREF parameter Set the HREF value to the URL of your Autodesk MapGuide Server along with the maps directory alias and the MWF f...

Page 21: ...t the view of the map window so that it displays only the area you want To display a specific area of a map 1 Right click over the map to display the popup menu and then use the Zoom commands or Pan to display the area of the map you want 2 Right click again and then choose Copy As URL to copy the map s URL to the clipboard 3 In your HTML document choose Edit Paste to paste the URL into the HREF p...

Page 22: ...h tags For example OBJECT ID map WIDTH 300 HEIGHT 200 CLASSID CLSID 62789780 B744 11D0 986B 00609731A21D PARAM NAME URL VALUE http www mapguide com maps usa mwf EMBED SRC http www mapguide com maps usa mwf NAME map WIDTH 300 HEIGHT 200 OBJECT For a list of the parameters that control the way the map is displayed when it is linked to or embedded in an HTML page choose Help Contents Advanced Topics ...

Page 23: ...the map can grow and shrink as the window is resized To see an example of a map within a simple frame based HTML page choose Help Contents Examples Basic Simple Frameset example in the Autodesk MapGuide Viewer API Help The following is an example of an HTML page for frame set layout HTML HEAD TITLE Frame Layout TITLE HEAD FRAMESET ROWS 70 FRAME SRC map htm NAME myFrame SCROLLING no MARGINHEIGHT 0 ...

Page 24: ...thod Map Display for the Java Edition Using Autodesk MapGuide Viewer Java Edition you cannot display a map by linking to it you must embed it The following are ways to embed a map Embed Autodesk MapGuide Viewer Java Edition in the HTML page where the map is embedded runs inside a Web browser Wrap a Java applet around Autodesk MapGuide Viewer Java Edition can run inside or outside of a Web browser ...

Page 25: ... choose Help Contents Plug In Java Edition Downloads in the Autodesk MapGuide Viewer API Help The MGMapApplet object provided by the MGMapApplet class file implements the MGMap object interface for Autodesk MapGuide Viewer Java Edition Setting the CODE parameter to MGApplet instantiates Autodesk MapGuide Viewer Java Edition 3 Set the VALUE parameter to the URL of your Autodesk MapGuide Server and ...

Page 26: ...apGuide Viewer types to view your maps To display a map using Autodesk MapGuide LiteView you send a URL request that returns the map displayed as a raster image file in the browser Note that you do not use the Autodesk MapGuide Viewer API with Autodesk MapGuide LiteView For complete information on implementing Autodesk MapGuide LiteView refer to the Autodesk MapGuide LiteView Developer s Guide The...

Page 27: ... installed If the user does not have the ActiveX Control or has an older version the latest version will be installed automatically In the following example the CODEBASE parameter references the mgaxctrl cab file located on the Autodesk MapGuide FTP site Alterna tively you can copy this file to your Web server and reference the file there You can find a copy of this file in the ActiveXCab folder o...

Page 28: ...lugins j name Autodesk MapGuide return If the Autodesk MapGuide Viewer Plug In is not detected display the message displayDownloadMsg return If the Autodesk MapGuide Viewer Plug In is installed check the version by returning the API version var version getMap getApiVersion If the API Plug In version is previous to 6 0 display the message if version 6 0 displayDownloadMsg return function displayDow...

Page 29: ...dition is not found the user is given the option to download it from the Autodesk MapGuide download page For this code to work the CheckInstall class file must reside in the same directory as the Web page that contains this code Alternatively you can add a CODEBASE parameter that points to the folder where this file exists For a working example choose Help Examples Advanced Java Edition Examples E...

Page 30: ...30 ...

Page 31: ...your application to work with map layers map features and printing as described in Chapter 4 Working with Map Layers Map Features and Printing Overview Map Access for ActiveX Control and Plug In Map Access for the Java Edition Communicating with the Plug In from a Java applet Accessing secure data Handling busy state and map refresh Handling errors Debugging an application ...

Page 32: ... for ActiveX Control and Plug In This section describes how to access maps from both Netscape Navigator and Internet Explorer The techniques described here use JavaScript as the scripting language Because Internet Explorer automatically recompiles JavaScript code into its native JScript you can write JavaScript code that works with either browser Suppose you embedded your map and named it map In N...

Page 33: ...you want as long as it follows JavaScript naming conventions Be careful to not to confuse the getMap function with MGMapLayer getMap a predefined Autodesk MapGuide Viewer API method After this function is defined any other JavaScript method can simply call getMap to retrieve the map object For example you can create a variable to represent the map and then use getMap to set the value of that varia...

Page 34: ...Read 4 When executing the JavaScript code Netscape Communicator will ask whether to Grant or Deny access to the script If you select Grant the script will run normally Otherwise the script is prevented from executing Because codebase principals offer a minimal level of security they can be useful during development of your code but you should use object signing and digital signatures before delive...

Page 35: ... simply embed Autodesk MapGuide Viewer Java Edition using the Applet tag This approach provides the following benefits You can post a map that most browsers and operating systems can access This is the simplest way to support Autodesk MapGuide Viewer Java Edi tion All you have to do is use the standard HTML Applet tag and set MGMapApplet as the code value Although this approach supports the greate...

Page 36: ...as COM objects instead of Java objects API methods that pass observer objects will not work For exam ple the digitizePoint method requires an instance of the MGDigitizePointObserver object Therefore Internet Explorer would not be able to access digitizePoint or any other methods that pass observer objects as arguments including the following MGMap methods If you need to use any of these methods im...

Page 37: ... Explorer which doesn t have full JScript support JavaScript JScript Support for Different Configurations Operating System Viewer Version JavaScript or JScript Support Windows Autodesk MapGuide Viewer Plug In on Netscape Navigator Full support Autodesk MapGuide Viewer ActiveX Control on Internet Explorer Autodesk MapGuide Viewer Java Edition on Netscape Navigator Autodesk MapGuide Viewer Java Edit...

Page 38: ... than driving Autodesk MapGuide 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 in the HTML document To run Autodesk MapGuide Viewer from a peer applet your...

Page 39: ... a development environ ment such as WebGain VisualCafe or Borland JBuilder be sure to include the mgjava jar file in your classpath If your application will handle events you will need to download the Java observer applet file MapGuideObserver6J class For more information about event handling with Autodesk MapGuide Viewer Java Edition see Chapter 5 Handling Events To download the Autodesk MapGuide...

Page 40: ...rowser For example if the URL for a map feature is set to javascript alert This is a private residence users will receive an error message when they double click that map fea ture in Internet Explorer This is because different browsers support differ ent protocols in the Java network library the previous example illustrates that Internet Explorer does not support the JavaScript protocol in the Jav...

Page 41: ...Map myUSAMap Public void setMap MGMap map1 myUSAMap map1 3 Add your applet to the HTML page You must include the MAYSCRIPT attribute in the APPLET tag to give the applet permission to interact with JavaScript For example APPLET code plugInApplet NAME obs WIDTH 400 HEIGHT 300 MAYSCRIPT APPLET 4 If you have not already done so embed Autodesk MapGuide Viewer Plug In in the HTML page as shown in the f...

Page 42: ... in the Netscape browser root directory You can download this filw from http developer netscape com software jdk download html This pack age provides access to the JSObject class containing the getWindow method which enables you to call JavaScript methods from your applet 2 The syntax for calling a JavaScript function from your applet is JSObject getWindow applet instance call function name parame...

Page 43: ...ure that the map fills up the entire frame In this case users will not be able to view the source code of the frame that displays the map You can then hard code the passkey in the source code of that frame Write a Java applet that makes a request for the passkey to your Autodesk MapGuide Server and then returns the passkey to the script in the Web page Call this applet in your embedded script afte...

Page 44: ...ake sure that Autodesk MapGuide Viewer is not in a busy state when your application calls one of the methods that are affected by the busy state Your application is most likely to fail when it is about to call two or more API methods the first an API method that automatically invokes a refresh and subsequent ones methods that don t work during the busy state For example function selectAndZoomToPoi...

Page 45: ... set error code to 14 refresh disabled because the onViewChanging and onMapLoaded events always disable the autoRefresh flag Using the autoRefresh Flag To develop an application that executes smoothly you need to prevent busy states while the application calls methods in the API that do not work during the busy state To do this you need to disable the autoRefresh flag To disable the autoRefresh Fl...

Page 46: ...er a version of the map that is different from the one on which the methods will be performing calculations Printing maps on dynamic layers and buffering features on dynamic layers Features that have not been downloaded onto the displayed map may not appear in the printout or the buffer Detecting Map Refreshes Autodesk MapGuide Viewer fires the onViewChanging and onViewChanged events both when a m...

Page 47: ...ons disable and re enable intermediate updates function disableIntermediateUpdates var map getMap var status map getIntermediateUpdatesEnabled if status true map setIntermediateUpdatesEnabled false function enableIntermediateUpdates var map getMap var status map getIntermediateUpdatesEnabled if status false map setIntermediateUpdatesEnabled true Handling Errors Every application should track and h...

Page 48: ...recently called method 1 Call the MGMap getLastError method to get the MGError object 2 Next call the MGError getArg method to get the number of the incorrect argument For example function checkArgType var map getMap var arg map getLastError getArg alert ERROR arg To see the argument types for any API method locate that method s Help topic in the Autodesk MapGuide Viewer API Help Debugging an Appl...

Page 49: ...on 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 described in Chapter 5 Handling Events Overview Working with map layers Working with map features Working with printing ...

Page 50: ...of Autodesk MapGuide Be careful not confuse the term object in these API names with the object oriented programming concept of objects For example the addObject method adds a map feature to the selection Likewise the MGMapObject object represents map features Working with Map Layers This section describes common tasks your application can perform with Autodesk MapGuide map layers Counting Map Laye...

Page 51: ...nally countLayers displays the count using the JavaScript alert func tion alert This map has cnt layer s Displaying the layer count Listing Map Layers The listLayers function counts the layers in a map and displays their names function listLayers var map getMap var layers map getMapLayersEx var cnt layers size var msg var i for i 0 i cnt i var layer layers item i msg msg layer getName n alert msg ...

Page 52: ...ments are processed var layer layers item i get next layer msg layer getName n add layer 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 vari able and then assigning that name to th...

Page 53: ...ax 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 for specific display ranges Refer to Setting Style Properties for Layers in the Autodesk MapGuide User s Guide For example you might set a layer to be inv...

Page 54: ...ity zipCodes getVisibility var layers thisMap getMapLayersEx for var i 0 i layers size i var layer layers item i if layer equals states layer equals counties layer equals zipCodes layer setVisibility vis The function starts by using the getMapLayer method to return each of the control layers as objects Those objects are assigned to three variables named states counties and zipCodes Next onViewChan...

Page 55: ...en it passes the function argument l_name to the getMapLayer method The getMapLayer function returns the specified layer or it returns null if the layer is not found The getMapLayer return value is then assigned to the layer variable var map getMap var layer map getMapLayer l_name Next the function checks the value of the layer variable If it is null an alert displays otherwise the setVisibility m...

Page 56: ...map getSelection var objs sel getMapObjectsEx null var cntObjects objs size var msg Keys of selected features are n var i for i 0 i cntObjects i var obj objs item i var key obj getKey msg msg obj getMapLayer getName key n alert msg The function starts by getting an instance of the MGMap object var map getMap Then it uses two API methods to see if any map features are selected Note that the methods...

Page 57: ...cted features are n var i loop counter variable for i 0 i cntObjects i iterate from 0 to cntObjects var obj objs item i var key obj getKey msg msg obj getMapLayer getName key n The cntObjects variable tells the for loop to iterate once for each object At each iteration the loop counter variable i is incremented and the following statements are processed var obj objs item i var key obj getKey msg m...

Page 58: ...ion displays a dialog box showing the coordi nates of a selected map feature doGet Coordinates Function function doGetCoordinates var map getMap var sel map getSelection var layer map getMapLayer Parcels if layer null alert No Parcels layer found in this map return if sel getNumObjects 1 sel getNumObjects 0 sel getMapObjectsEx layer size 0 alert Select only one parcel please return var obj sel get...

Page 59: ...d in this map return Next doGetCoordinates uses the getNumObjects and getMapObjectsEx methods to verify that one and only one feature is selected and that the current layer is not empty If the criteria are not met an alert displays and the function terminates if sel getNumObjects 1 sel getNumObjects 0 sel getMapObjectsEx layer size 0 alert Select only one parcel please return var cntVertices map c...

Page 60: ...rtices vertices cntVertices if res 0 alert No access to coordinate information return Next doGetCoordinates uses a for loop to cycle through the vertices collection placing all of the coordinate listings in a single msg variable msg Parcel obj getKey n msg msg Coordinates in MCS unit n for var i 0 i cntVertices item 0 i var pnt vertices item i msg msg pnt getX pnt getY n The cntVertices variable t...

Page 61: ...enated API methods to 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 by using getMapObjectsEx with the selection object and passing it null it returns the...

Page 62: ...legend var legendSet Global variable declared outside of function function showFeatureCount if legendSet return var map getMap if map isBusy false can also be written as if map isBusy var layers map getMapLayersEx var cnt layers size var i var msg for i 0 i cnt i var layer layers item i var objectCount layer getMapObjectsEx size var label layer getLegendLabel label label objectCount features layer...

Page 63: ...LayersEx method to obtain a layer collection and assign it to a variable called layers Then it uses the size method to get the number of layers and assign that number to the cnt variable var layers map getMapLayersEx var cnt layers size Then it creates a loop that counts the features in each layer and uses the getLegendLabel and setLegendLabel methods as shown in the illustra tions following the e...

Page 64: ...he API supports these user interface features and also provides additional functionality allowing you to write code to change the title font add a custom symbol or control the size and position of any page element on the printout As a developer you can specify that two events be fired each time a map is sent to the printer The first event onBeginLayout is fired after a user clicks OK in the Print ...

Page 65: ... 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 between 0 0 and 100 0 that describes the relative printing order of a page element The element with the lowest number is printed first The element with the highest number is printed last You can read and change an ele...

Page 66: ...p el_arrow setPrintPriority el_map getPrintPriority 1 Enabling the Print Events By default the onBeginLayout and onEndLayout events are not fired you enable and disable them using the enablePrintingEvents and disablePrintingEvents methods For Autodesk MapGuide Viewer Plug In and Autodesk MapGuide Viewer Java Edition you will also need to use the setPrintingObserver method to specify the event obse...

Page 67: ...ate 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 margins Unlike the coordinate system that is used on a map the Y values increase in the downward direction and the X values increase to the right Like the device unit type the default PCS unit type is a pixel ...

Page 68: ...Autodesk MapGuide Help for more information The following example shows an onEndLayout event handler written in JavaScript that adds a custom logo to the top left corner of the printout Note that the logo is rotated 90 This example assumes that the myLogo symbol has been added to the API symbol list by the map author function onEndLayout layout info add myLogo symbol to layout and return as sym va...

Page 69: ...re con trol over how your application responds to actions by users as they view maps Once your application can han dle Autodesk MapGuide Viewer events you may want to add data query and update capabilities as described in Chapter 6 Using Reports to Query and Update Data Sources Overview Working with event handlers Setting up event handlers Writing event handlers ...

Page 70: ...this This type of function which works only in response to an event is called an event handler For Microsoft Internet Explorer you write VBScript code to set up the event handlers for your application VBScript a lightweight Visual Basic like scripting language For Netscape Navigator you need to set up event observers Event observers act as the link between the event and your event handling code th...

Page 71: ...ents just for the events you want to handle Netscape Navigator Internet Explorer For Netscape Navigator Autodesk MapGuide provides an observer applet that you embed in your application using the APPLET tag For Autodesk MapGuide Viewer Plug In this applet is called MapGuideObserver6 class For Autodesk MapGuide Viewer Java Edition it is called MapGuideObserver6J class You can use the same instance o...

Page 72: ...odesk MapGuide Viewer is present on the client s system You can do this by embedding a detection applet provided by Autodesk MapGuide This applet is included in an archive file called MGDetectClass zip The detection applet can detect whether or not Autodesk MapGuide Viewer Java Edition has been installed on a client system To download event observer and detection applet code choose Help Contents P...

Page 73: ...owing code shows how to check the Autodesk MapGuide Viewer version and install the appropriate event observer applet for Autodesk MapGuide Viewer Plug In or Autodesk MapGuide Viewer Java Edition Installing Plug In and Java Editions Observer Applets SCRIPT LANGUAGE JavaScript Embed the detect applet to check if the Autodesk MapGuide Viewer Java Edition is installed document write APPLET document wr...

Page 74: ...s not installed so we check to see if the browser is Netscape else if navigator appName Netscape The browser is Netscape so we embed the Autodesk MapGuide Viewer Plug In Observer Applet document write Java Applet CODE MapGuideObserver6 class WIDTH 2 HEIGHT 2 NAME obs MAYSCRIPT document write Java Applet function onLoad if navigator appName Netscape getMap setSelectionChangedObserver document obs f...

Page 75: ...ample in response to an onSelectionChanged event Internet Explorer looks for a function named mapName_onSelectionChanged 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 onDigitizedPo...

Page 76: ...DigitizeIt The DigitizeIt function calls the digitizePoint method an Autodesk MapGuide Viewer API method that waits for the user to click a point on the map and then captures that point For Netscape Navigator the digitizePoint method requires an event observer as a parameter whereas Internet Explorer does not Here is the code for both function digitizeIt if navigator appName Navigator getMap digit...

Page 77: ...r or the page will not load correctly in Internet Explorer The applet is given the name obs After the page loads the browser automatically calls the onLoad function onLoad calls the setSelectionChangedObserver method from MGMap providing the Autodesk MapGuide Viewer Plug In and its observer applet with the observer object that handles selection changed events Finally the map_onSelectionChanged fun...

Page 78: ...p_onSelectionChanged map onSelectionChanged map End Sub SCRIPT The following JavaScript function processes events for both the Autodesk MapGuide Viewer ActiveX Control and Autodesk MapGuide Viewer Plug In Autodesk MapGuide Viewer ActiveX Control events are forwarded to this function via VBScript and Autodesk MapGuide Viewer Plug In events are forwarded to this function via the Autodesk MapGuide Vi...

Page 79: ... the page The following example shows one way to write an onBeginLayout event handler in JavaScript that suppresses all page elements except the map The example assumes you ve set up the event handlers as described in Setting Up Event Handlers on page 72 and enabled print events as described in Enabling the Print Events on page 66 To suppress page elements except the map 1 Create a button on the H...

Page 80: ...r extends Applet implements MGPrintingObserver public void onBeginLayout MGPageSetup pgSetup MGPrintInfo info turn off all elements except the map pgSetup setInclude mg_scalebar false pgSetup setInclude mg_northarrow false pgSetup setInclude mg_title false pgSetup setInclude mg_timestamp false pgSetup setInclude mg_legend false Note You can control the Page Setup without using the onBeginLayout ev...

Page 81: ...ize of the printable area of the page The following example shows one way to write a print event handler in Java Script that adds a custom symbol myLogo to the printout The example assumes you ve set up the event handlers as described in Setting Up Event Handlers on page 72 and enabled print events as described in Enabling the Print Events on page 66 To add a custom symbol to the printout 1 Create...

Page 82: ...set the width and height of the logo to 1 by 1 logoExt set mapExt getMinX mapExt getMinY mapExt getMinX pixelsPerInch mapExt getMinY pixelsPerInch logoEle setExtent logoExt The following code shows how to implement the same event handler for the onEndLayout event in Java public class MyObserver extends Applet implements MGPrintingObserver public void onEndLayout MGPrintLayout layout MGPrintInfo in...

Page 83: ...is method For example public class myApplet extends applet implements MGDigitizeCircleObserver public void onDigitizedCircle MGMap map String units MGPoint center double radius Place your event handling code here Now your applet can act as an 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 paramet...

Page 84: ...84 ...

Page 85: ...ase information associated with a map This chapter explains how Autodesk MapGuide generates reports and shows you how to create report scripts using two popular server side technologies Macromedia ColdFusion and Microsoft Active Server Pages Overview Introducing ColdFusion and ASP Creating report scripts with ColdFusion Creating report scripts with ASP ...

Page 86: ...onstruct a URL dynamically and send it as an HTTP request to a Web server This URL is composed of a path to an application on the Web server along with a set of parameters The server in turn will process the request and send or post the results Autodesk MapGuide can generate two distinct types of requests by passing unique parameters along with the URL to the server The first type of URL request p...

Page 87: ...nstead You set the key column type by selecting it from the Type list box on the Data Sources tab of the Map Layer Properties dialog box in Autodesk MapGuide Author Launching the Report You can launch the View Reports dialog box from Autodesk MapGuide Viewer by right clicking the map and choosing View Reports or by clicking the Report button on the Autodesk MapGuide Viewer toolbar Both methods wil...

Page 88: ...se the HTML can include anything even client side scripting code Although end users can view the source of your HTML output they never see the server side scripting code used to create that output This developer s guide uses ColdFusion and ASP for its examples because developing with these products is easier than writing your own Perl scripts or Visual Basic C DLLs and because these products are b...

Page 89: ...owing examples show how to create report scripts with ColdFusion We recommend that you read them in order Note For ASP versions of the same examples see Creating Report Scripts with ASP on page 109 Listing File Contents with ColdFusion This example shows a simple template that lists the contents of a map resource database Note that this template accesses the database directly instead of using the ...

Page 90: ...rolling the Output Now we ll assemble the CFOUTPUT statement If you want to display the parcel number owner s name and year built your tag will look like this CFOUTPUT QUERY get_parcel_info P Parcel Number APN BR P Owner Name Owner_Name BR P Year Built Year_Built P CFOUTPUT The QUERY attribute tells ColdFusion which recordset you d like to display this attribute matches the NAME you specified in C...

Page 91: ...ith ColdFusion H1 ColdFusion output tags CFOUTPUT QUERY get_parcel_info P Parcel Number APN BR Owner Owner_Name BR Year Built Year_Built P CFOUTPUT BODY HTML The following shows the page as it appears in a browser The HTML output In this example the database happens to be an Autodesk MapGuide resource but it could be anything a Microsoft Access database listing employees and their phone numbers a ...

Page 92: ...p mwf file from the Autodesk MapGuide Web site Note that the full set of Starter Application files is avail able for download at http www autodesk com mapguidedemo 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 CF and it will access a CFM file whose URL is http www yourserver com parce...

Page 93: ...r Parameter Specifies the name of the URL parameter used to send the feature key or keys to parcel_report cfm The name can be anything you want as long as it matches the name you specified in parcel_report cfm We ve selected the Autodesk MapGuide Author default OBJ_KEYS When a user selects one or more features from the Assessment layer and runs the Parcel Data CF report Autodesk MapGuide construct...

Page 94: ...age 89 The only change is to the CFQUERY tag which uses a different SQL statement SELECT FROM Parcel_Data Where APN IN PreserveSingleQuotes OBJ_KEYS 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 a ColdFusion variable PreserveSingleQuotes OBJ_KEYS The OBJ_KEYS values refer to the parameter of the same ...

Page 95: ...ide Report P embedded map OBJECT ID map WIDTH 600 HEIGHT 250 CLASSID CLSID 62789780 B744 11D0 986B 00609731A21D PARAM NAME URL VALUE http www yourserver com maps StarterApp mwf EMBED SRC http www yourserver com maps StarterApp mwf NAME map WIDTH 600 HEIGHT 250 OBJECT BODY HTML Seeing the Results Users can now generate a report for one or more map features by selecting the map features right clicki...

Page 96: ...k to the parcel_map htm file and modify the embedded map code OBJECT ID map width 600 height 250 CLASSID CLSID 62789780 B744 11D0 986B 00609731A21D PARAM NAME URL VALUE http www yourserver com maps StarterApp mwf ReportTarget _self EMBED src http www yourserver com maps StarterApp mwf ReportTarget _self NAME map WIDTH 600 HEIGHT 250 OBJECT Notice that we ve added a Autodesk MapGuide Viewer URL par...

Page 97: ...ent 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 and the loca tion they zoomed to has been lost A better approach is to display the map and the report in two frames of the ...

Page 98: ...t we have assigned the names Left and Right to the frames The source for Left is parcel_map htm the file containing our embedded map The source for Right is about blank a standard browser function whose purpose is to display a blank window or frame Now that we have the frameset let us go back to the parcel_map htm file and change the ReportTarget parameter to Right the name we assigned to our righ...

Page 99: ...llowing 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 ...

Page 100: ...line of text to the right hand frame of our report application You will notice that the text instructs users to select one or more map features This instruction displays each time runReport is invoked regardless of whether the user has selected features If features are selected the instruc tions are replaced in the frame by the contents of the newly generated report otherwise the instructions rema...

Page 101: ...vaScript functions SCRIPT function 1 function getMap if navigator appName Netscape return parent Left document map else return parent Left window map function 2 function runReport parent Right document write P Select one or more parcels first P getMap viewReport Parcel Data CF SCRIPT HEAD BODY H1 Querying and Displaying Data via the Map H1 P This example uses b ColdFusion b to access an Autodesk M...

Page 102: ...n stored in a database on the server and are visible to anyone else viewing the map The example shows a hypothetical Incident Log application that will be used to track crimes and consists of the following components Three ColdFusion files getpoint cfm showform cfm and insert cfm As their names suggest the files receive point coordinates from Autodesk MapGuide display a form that takes additional ...

Page 103: ...int cfm Dialog box specifications for Incidents CF report Here are descriptions of how we used the options on the Reports tab Report Specifies the name of the report as it appears in the Autodesk MapGuide Viewer Our report is named Incidents CF URL Specifies the name and location of the report script in this case get point cfm on www yourserver com Data We left this field blank but could have used...

Page 104: ...JavaScript code because the file doesn t display any text no other HTML tags are needed Let s look at the code line by line When getpoint cfm is first called it uses a default browser window similar to the one we saw in the previous example The first line of code closes that window Note Because the browser parses the entire SCRIPT block before running the first line of code we can safely close the...

Page 105: ...orm cfm file does indeed show a form which is used to enter a description of the incident The bulk of the file is a standard HTML form The form has been placed within CFOUTPUT tags to give us access to the ColdFusion variables LAT and LON Once again these variables are replaced on the server by the user specified lat lon coordinates In short an HTML form collects data from the user and sends that ...

Page 106: ... 943 rpt_info A hat was stolen rpt_by J Bigby Now let s see how the insert cfm file handles the URL CFQUERY NAME InsertQuery DATASOURCE assessor INSERT into Incidents lat lon description reported_by values FORM rpt_lat FORM rpt_lon FORM rpt_info FORM rpt_by CFQUERY SCRIPT LANGUAGE JavaScript alert Point added successfully Reload the map to see your changes window close SCRIPT The file consists of ...

Page 107: ...y our map we ll use parcel_map htm modi fying only the H1 and the short paragraph of descriptive text HTML HEAD TITLE ColdFusion Example TITLE HEAD BODY Only the next two lines are different H1 Modifying a Database via the Map H1 P This example uses b ColdFusion b to update a database map resource P embedded map OBJECT ID map WIDTH 600 HEIGHT 250 CLASSID CLSID 62789780 B744 11D0 986B 00609731A21D ...

Page 108: ...es the task to be performed by the menu item We selected GetPointAndSendToURL from the drop down list Arguments Specifies arguments to use with the selected action in this case the path to getpoint cfm and the name of the layer to add data to When users select Incident Log from the popup menu they will immediately be able to enter a point thus bypassing several mouse clicks Also if the Inci dents ...

Page 109: ...on is designed specifically for Web database connectivity ASP is a more general development environment On one hand this means you can do more with ASP than with ColdFusion On the other hand it takes longer to learn to do anything at all with ASP Both products are excellent but if you re a non programmer you ll probably be happier with ColdFusion Much ASP functionality is provided by objects and c...

Page 110: ...er continues the session Request Parses data submitted from the client to the server Response Manages content returned to a browser by ASP Server Provides a number of useful server methods including CreateObject which you ll use to create a connection to your database map resources Components Used to Create a Report Script Component Description Database Access Reads and writes to OLE DB data sourc...

Page 111: ...atabase at the bottom of an HTML page displaying the map you would first rename the HTML file with an asp extension and place it in a directory with script or execute permissions Then you would add some code to specify the scripting language establish a connection to the appropriate database records and control the database output The next sections describe each of those tasks in more detail Event...

Page 112: ... this Set dbConnection Server CreateObject ADODB Connection dbConnection Open Assessor SQLQuery SELECT FROM Parcel_Data Where Year_Built 1963 Set RS dbConnection Execute SQLQuery This might seem complicated compared to ColdFusion s CFQUERY tag but it will look familiar to Visual Basic programmers The end result is a Recordset object variable RS which represents all houses in Parcel_Data that have ...

Page 113: ...your output code will look like this Do While Not RS EOF P Parcel Number RS APN BR Owner RS Owner_Name BR Year Built RS Year_Built P RS MoveNext Loop If you re accustomed to client side scripting this code might look peculiar Notice how it is actually two different script tags that operate on HTML code sandwiched in the middle Let s look at the HTML portion first P Parcel Number RS APN BR Owner RS...

Page 114: ...ock contains two lines one that advances to the next record in the recordset and another that finishes up the loop structure RS MoveNext Loop Now we re ready to load the page in our browser Seeing the Results Here s a listing of the complete ASP file parcel_report asp HTML HEAD code to create recordset Set dbConnection Server CreateObject ADODB Connection dbConnection Open Assessor SQLQuery SELECT...

Page 115: ...t it could be any database you have access to through a DSN In most cases you will want to access your data bases through the Autodesk MapGuide Viewer by linking them to features and layers in the map The examples that follow show you how to do this Querying and Displaying Data via the Map with ASP Now that we ve seen how ASP works let s use it with Autodesk MapGuide This example uses the StarterA...

Page 116: ...ifies the name and location of the report script in this case parcel_report asp on www yourserver com Data We left this field blank but could have used it to pass additional URL parameters to parcel_report asp For example if our server page con tained definitions for more than one query we could have passed a parameter telling the file which of the queries to run Type Specifies whether the report ...

Page 117: ...ameter To ASP this parameter is no different from one submitted by an HTML form element As we ll see in the next section ASP processes it accordingly Creating the Report Script Now let s create the ASP file that will process the Autodesk MapGuide report The following code listing is for the parcel_report asp file HTML HEAD TITLE ASP Report Data TITLE HEAD BODY code to create recordset Set dbConnec...

Page 118: ...lect in Parcel_Data all records whose APN field matches OBJ_KEYS In other words select the records that correspond to the selected features on the map If OBJ_KEYS contains multiple keys ASP outputs the feature data associated with each key Creating an HTML Page to Display the Map The last step is to create an HTML page to display our map The following listing is for the parcel_map htm file HTML HE...

Page 119: ...g 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 ASP Displaying the parcel data report in a new window This report looks pretty good but we can still do a few things to improve the interface ...

Page 120: ...1A21D PARAM NAME URL VALUE http www yourserver com maps StarterApp mwf ReportTarget _self EMBED src http www yourserver com maps StarterApp mwf ReportTarget _self NAME map WIDTH 600 HEIGHT 250 OBJECT Notice that we ve added a Autodesk MapGuide Viewer URL parameter to the map reference http www yourserver com maps StarterApp mwf ReportTarget _self ReportTarget specifies the window or frame in which...

Page 121: ... 10 SCROLLING auto FRAMEBORDER yes FRAMESET HTML Notice that we ve assigned the names Left and Right to the frames The source for Left is parcel_map htm the file containing our embedded map The source for Right is about blank a standard browser function whose purpose is to display a blank window or frame We have the frameset so let s go back to the parcel_map htm file and change the ReportTarget p...

Page 122: ...oosing View Reports from the popup menu We ll create a Parcel Report button that will display the report First we ll add the following SCRIPT tag to the parcel_map htm file SCRIPT function getMap if navigator appName Netscape return parent Left document map else return parent Left window map function runReport parent Right document write P Select one or more parcels first P getMap viewReport Parce...

Page 123: ... to a third party JavaScript manual for more information on writing to frames and windows The second statement uses the viewReport method to run our report and begins by calling getMap which returns the appropriate map feature That feature is then passed to viewReport which directs Autodesk MapGuide to display Parcel Data ASP Now that our function is defined to call it we ll add a FORM element to ...

Page 124: ... 2 function runReport parent Right document write P Select one or more parcels first P getMap viewReport Parcel Data ASP SCRIPT HEAD BODY H1 Querying and Displaying Data via the Map H1 P This example uses b ASP b to access an Autodesk MapGuide Report P embedded map OBJECT ID map WIDTH 600 HEIGHT 250 CLASSID CLSID 62789780 B744 11D0 986B 00609731A21D PARAM NAME URL VALUE http www yourserver com map...

Page 125: ... components Three server pages getpoint asp showform asp and insert asp As their names suggest the files receive point coordinates from Autodesk MapGuide display a form that takes additional user input and add the point data to a database on the server An Autodesk MapGuide report and later a custom menu item that passes digitized point coordinates to the getpoint asp file An HTML page to host the ...

Page 126: ... on www yourserver com Data We left this field blank but could have used it to pass additional URL parameters to getpoint asp 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 Prompt Specifies the text to be displayed in a message box prompting users to specify a po...

Page 127: ...gy will get you into trouble if your file contains function calls or other multiple SCRIPT blocks See your JavaScript documentation for more information The next line constructs a URL and assigns it to a variable called loc Note that the line is a mix of both JavaScript and ASP code The ASP code is processed first on the server Then the line is sent to the browser as standard JavaScript Let s look...

Page 128: ...it VALUE OK INPUT TYPE button NAME CancelButton VALUE Cancel onClick window close CENTER FORM BODY HTML The showform asp file shows a form used to enter a description of the inci dent The form follows HTML syntax but also contains the ASP variables Request QueryString lat Request QueryString lon The Request QueryString collection is similar to Request Form but instead of holding HTML form values t...

Page 129: ...his value is passed as the form parameter rpt_lat The longitude value obtained from the ASP variable Request QueryString lon this value is passed as the form parameter rpt_lon An incident description entered in the form by a user this description is passed as the form parameter rpt_info A name entered in the form by a user this name is passed as the form parameter rpt_by The following illustration...

Page 130: ...e One is an ASP script written in VBScript The other is an HTML SCRIPT element containing JavaScript code The first line of code uses the CreateObject method of the Server object to create a new Connection object which is assigned to a variable called dbConnection The next line opens a connection to the data source name DSN in this case Assessor and assigns that connection to the dbConnection vari...

Page 131: ...y the original map window Creating an HTML Page to Display the Map The last step is to create an HTML page to display our map We ll use the parcel_map htm file from the previous example modifying the H1 and the short paragraph of descriptive text but leaving the rest of the file unchanged HTML HEAD TITLE ASP Example TITLE HEAD BODY Only the next two lines are different H1 Modifying a Database via ...

Page 132: ...es dialog box Dialog box specifications for Incident Log popup menu item Here are descriptions of how we used the options on the Popup Menu tab New Menu Item Creates a new popup menu item below the item selected in the Popup Menu list Name Specifies the name of the menu item as it will appear in the Autodesk MapGuide Viewer Our menu item is named Incident Log Action Specifies the task to be perfor...

Page 133: ...or 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 other interface element to the HTML page hosting the map or to a frame or child window with programmatic access to that page The button should invoke a JavaScript function that does the following Uses the digitiz...

Page 134: ...134 ...

Page 135: ...ures of the Autodesk MapGuide Viewer API by describing and including source code for several applications Overview Custom redlining application Municipal application Facility management application DWG filtering application SDF Component Toolkit applications ...

Page 136: ...riginal document You can use the Autodesk MapGuide Viewer API to create a custom redlining application that allows users to mark up a map using the Autodesk MapGuide Viewer The user s markups are saved to a special layer type called a client redline layer Client markups can be printed or saved along with the rest of the map to an MWF You can make your application as sophisticated as your needs war...

Page 137: ...g Example Code The following example shows one way to write a simple redlining applica tion It lets the user create a redlining layer add polygon objects to that layer and save the map to a drive on a local machine The user interface is sparse consisting of a small HTML form with a text box and two buttons as shown in the following illustration Redlining example Here is the code for the form FORM ...

Page 138: ...ePolygon The digitizePolygon and digitizePolygonEx methods both fire the onDigitizedPolygon event passing it the map object the number of polygon vertices and the coordinates of those vertices The onDigitizedPolygon event looks for a JavaScript function of the same name and if that function exists executes it In fact the onDigitizedPolygon function does exist because we ve created it Here s the co...

Page 139: ...MGTextAttr and MGRedlineSetup For information about querying redline objects look up MGPrimitive 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 numPoints use MGCollection to create polyline primitive and add it to redline ...

Page 140: ...legend allows you to turn 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 time and turn off the raster layer These controls are useful for finding information...

Page 141: ...letters of tempName to browserName variable var tempName navigator appName var browserName tempName substring 0 8 Map object variable to be used later var map Set browserId variable 1 for netscape 2 for IE else 0 if browserName Netscape var browserId 1 else if browserName Microsof just first 8 letters browserId 2 else browserId 0 Function getMap Description Get appropriate map object for IE or Net...

Page 142: ...w Function starts here function CreateInWindow Set URL variable to location of ColdFusion file used to generate report then open URL in new window called InWindow var URL http www gridnorth com interdemo municipal reports Incident1 cfm InWindow open URL InWindow toolbar no width 480 height 350 directories no status no scrollbars YES resizable YES menubar no Function notifyoff Description Closes wi...

Page 143: ...ff make the layer invisible otherwise make the layer visible if type Off mapLayer1 setVisibility false else mapLayer1 setVisibility true Tell the Autodesk MapGuide Viewer to rebuild layer when map is refreshed then refresh map mapLayer1 setRebuild true map refresh If Autodesk MapGuide Viewer is busy don t do the stuff above instead display alert else alert The Autodesk MapGuide Viewer is busy Plea...

Page 144: ... Acct var mapLayer12 map getMapLayer Water 3 inch Valves var mapLayer13 map getMapLayer Water Point of Service var mapLayer14 map getMapLayer Water Distribution var mapLayer15 map getMapLayer Water 3 inch Distribution var mapLayer16 map getMapLayer Marin County Land Parcels var mapLayer17 map getMapLayer Population Density var mapLayer18 map getMapLayer ZIP Codes var mapLayer19 map getMapLayer Cou...

Page 145: ...odesk MapGuide Viewer is not busy get current map scale then assign San Rafael layer to mapRastLayer variable if map isBusy false var CurrentScale map getScale var mapRastLayer map getMapLayer San Rafael If scale is less than 1 20 000 and if function was called with On make mapRastLayer visible if CurrentScale 20000 type On mapRastLayer setVisibility true mapRastLayer setRebuild true map refresh I...

Page 146: ...cludes a form that lets enter text and add that text to the map as point data Arguments none Returns nothing function digit Use browserId variable defined at beginning of script to determine if user has Netscape or Internet Explorer doesn t bother to call getMap because entire function varies by browser If Netscape if browserId 1 Get instance of MGMap assign to map variable map parent main documen...

Page 147: ...thing function reporter map getMap Get instance of MGMap If Autodesk MapGuide Viewer is not busy if map isBusy false Get object representing current selection assign then get number of map features in that selection var sel map getSelection var NumSel sel getNumObjects If selection has at least one object display View Reports dialog otherwise display alert if NumSel 0 map viewReportsDlg else alert...

Page 148: ...ApiVersion map getApiVersion if ApiVersion 6 0 alert This control uses the latest technology in the n Autodesk MapGuide Viewer API Please n download the latest Autodesk MapGuide Viewer from the Autodesk MapGuide n Web site www autodesk com mapguideviewerdownload If user has recent copy of Autodesk MapGuide Viewer API version 6 0 or greater else Assign array of possible drop down list options to se...

Page 149: ...or var i 0 i selValue length i if selValue i selected var temp2 selValue i value The temp2 variable now represents user s selection use it to assign appropriate date related SQL statement to the whereClause2 variable date is generated on the server by Coldfusion then sent to the browser as text if temp2 today whereClause2 ReportDate 04 01 99 AND ReportDate 04 01 99 else if temp2 last2days whereCla...

Page 150: ...up Run SQL statement you created on the database linked to the Incidents layer then refresh the map causing the items you queried to display in the map mapDatabaseSetup setWhereClause whereClause map refresh Function pageSetup Description Displays the page setup dialog called by the Print Setup button under Print Map Arguments none Returns nothing function pageSetup map getMap Get instance of MGMa...

Page 151: ...he JavaScript functions defined above HEAD BODY BGCOLOR CCCC99 Remainder of page is FORM containing a nested table FORM NAME Selection Begin table 1 TABLE CELLPADDING 0 CELLSPACING 0 BORDER 0 WIDTH 100 TR TD VALIGN top width 100 Begin table 2 TABLE CELLPADDING 2 CELLSPACING 3 BORDER 0 WIDTH 100 TR TD BGCOLOR FFFFFF VALIGN MIDDLE ALIGN CENTER IMG SRC menu mdcp gif WIDTH 105 HEIGHT 31 BORDER 0 BR TD...

Page 152: ...TH 30 HEIGHT 21 BORDER 0 A BR TD TR TABLE End table 4 TD TR TABLE End table 3 Begin table 5 TABLE CELLPADDING 2 CELLSPACING 3 BORDER 0 WIDTH 100 TR TD VALIGN MIDDLE BGCOLOR 9c9c63 A HREF app98help cfm digimg IMG SRC MENU qs gif WIDTH 21 HEIGHT 18 BORDER 0 ALIGN right A IMG SRC menu lc gif WIDTH 93 HEIGHT 18 BORDER 0 BR TD TR TR TD VALIGN MIDDLE ALIGN CENTER Begin table 6 TABLE CELLPADDING 0 CELLSP...

Page 153: ...C MENU ON gif WIDTH 30 HEIGHT 21 BORDER 0 A BR TD TD A HREF JavaScript vector Off IMG SRC MENU OFF gif WIDTH 30 HEIGHT 21 BORDER 0 A BR TD TR TABLE End table 7 Begin table 8 TABLE CELLPADDING 0 CELLSPACING 0 BORDER 0 TR TD IMG SRC menu raster gif WIDTH 75 HEIGHT 21 BR TD TD A HREF JavaScript raster On IMG SRC MENU ON gif WIDTH 30 HEIGHT 21 BORDER 0 A BR TD TD A HREF JavaScript raster Off IMG SRC M...

Page 154: ... End table 9 Begin table 10 TABLE CELLPADDING 0 CELLSPACING 0 BORDER 0 TR TD COLSPAN 1 ALIGN CENTER IMG SRC menu b_date gif WIDTH 27 HEIGHT 12 ALT BORDER 0 TD TD SELECT NAME myDate SIZE 1 onChange showIncidents OPTION VALUE showAll Show all OPTION VALUE today Today OPTION VALUE last2days Last 2 days OPTION VALUE last7days Last 7 days OPTION VALUE last15days Last 15 days OPTION VALUE last30days Las...

Page 155: ... 18 BORDER 0 align right A IMG SRC menu prnmap gif WIDTH 64 HEIGHT 18 BORDER 0 BR TD TR TR TD VALIGN MIDDLE ALIGN CENTER A HREF JavaScript pageSetup IMG SRC MENU prnsetup gif WIDTH 107 HEIGHT 19 BORDER 0 a BR A HREF JavaScript printMap IMG SRC MENU print gif WIDTH 107 HEIGHT 19 BORDER 0 a BR TD TR TABLE End table 11 TD TR TABLE End table 1 FORM BODY HTML Municipal Application Example Code continue...

Page 156: ...agement 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 the window It also allows you to select features in various ways generate reports and even search for an employee and update his or her information Facility Management application ...

Page 157: ...tion Example Code HTML HEAD TITLE FM TITLE SCRIPT LANGUAGE JavaScript Get full browser name and assign it to tempName variable then assign first 8 letters of tempName to browserName variable var tempName navigator appName var browserName tempName substring 0 8 Map object variable to be used later var map Set browserId variable 1 for netscape 2 for IE else 0 if browserName Netscape var browserId 1 ...

Page 158: ...e number as the scrolling factor else if direction Up direction Down direction Left direction Right direction Ul direction Ur direction Ld direction Rd delta map getWidth M delta scrollfactor 10 delta Compute center point of map in Mapping Coordinate System MCS var xyPt map lonLatToMcs map getLon map getLat Convert delta from Meters to MCS units var MCStoMeters map getMCSScaleFactor delta delta MC...

Page 159: ...e map setAutoRefresh true map refresh ends panning Function GoToOrig lat lon Description Zooms to the lat lon specified with a width of 400 ft Arguments lat lon Returns nothing function GoToOrig lat lon var map getMap map zoomWidth lat lon 400 FT Function reportsDlg Description shows the reports dialog for generating reports Arguments none Return none function reportsDlg var map getMap var sel map...

Page 160: ...rt 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 function selMapObj var map getMap map selectMapObjectsDlg Function selRadiusMode Description changes the selection mode to select by radius Arguments none Return none function selRadiusMode var map getMap map selec...

Page 161: ...om the map Keep track of them in a vector for var i 0 i selOptions length i if selOptions i selected var obj mapLayer getMapObject selOptions i value if obj null collection add obj sel clear if collection size 0 sel addObjectsEx collection false var zoomCheck document Selection ZoomOption checked if zoomCheck true map zoomSelected Function showOccupancy Description on change of selection show occu...

Page 162: ...Function openSearchWind Description used to launch the search popup window Arguments none Return none function openSearchWind var FirstName document Selection FirstName value var LastName document Selection LastName value var RoomSelected var Count 0 var selOptions document Selection roomnum options for var i 0 i selOptions length i if selOptions i selected RoomSelected selOptions i value Count Co...

Page 163: ... 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 SCRIPT HEAD Facilities Management Application Example Code continued ...

Page 164: ...ples Advanced DWG Filtering Example in the Autodesk MapGuide Viewer API Help As shown in the following illustration the list box to the right of the map shows the DWG filters that can be applied to an architectural map of a floor plan When a user selects one or more filters from the list box the corre sponding Autodesk DWG layer s is displayed on the map The user can also select one or more featur...

Page 165: ...urce properties for that layer For example if you changed the DWG data source using the MGDwgDataSources setDataSource method or the MGDwgDataSources DataSource property this change could make existing values for other properties such as the Autodesk DWG file invalid since they might not exist in the new data source Layer Type Definition Autodesk DWG layer A single layer within an Autodesk drawing...

Page 166: ... This function is called when a user selects or deselects one or more DWG filters from a list box displayed on the map page This function sets the layer filter of the DWG map layer to layers selected by the user The basic operational flow of this function is as follows 1 Use the getMap function the current map is assigned to the variable map 2 Use the map getMapLayer method to get the map s single...

Page 167: ...tup getDwgDataSources Create a collection object to hold filters selected fromlist box var mapDwgLayerFilters map createObject MGCollection Iterate through list box selections and add each to the collection var selOptions document forms 0 filters options for var i 0 i selOptions length i if selOptions i selected var selectedFilter selOptions i value if selectedFilter null mapDwgLayerFilters add se...

Page 168: ...Layer getName method 6 Get the map layer and its DWG data source object To do this we first get the map layer using map getMapLayer with the layer name then get the layer setup using mapLayer getLayerSetup method Then we get the DWG data sources object of the layer using mapLayerSetup getDwgDataSources 7 Using MGDwgDataSources methods we get the DWG properties of the map layer including getDataSou...

Page 169: ...D Get the map layer and its DWG data source object var mapLayer map getMapLayer layerName var mapLayerSetup mapLayer getLayerSetup var dwgMapLayerDataSource mapLayerSetup getDwgDataSources parent outputframe document write TD parent outputframe document write dwgMapLayerDataSource getDataSource parent outputframe document write TD parent outputframe document write TD parent outputframe document wr...

Page 170: ...rame document write dwgMapLayerDataSource getNameTable parent outputframe document write TD parent outputframe document write TD parent outputframe document write dwgMapLayerDataSource getUrlColumn parent outputframe document write TD parent outputframe document write TD parent outputframe document write dwgMapLayerDataSource getUrlTable parent outputframe document write TD parent outputframe docu...

Page 171: ...Example You can use the SDF Component Toolkit to create server side applications that read and modify existing SDF files These applications can interact with client side scripts allowing for dynamic updates based on user input For example you could create an application that lets users add polygon lot lines or points of interest to a map from their browser You can use the SDF Component Toolkit to ...

Page 172: ...tton The new point and its name are added to poi sdf which is the SDF file on which the Points of Interest map layer is based Points are represented on the map as L shaped symbols To find the point again type the name of the point and click the Find button The map zooms to the point To select the point either click it or right click to display the popup menu choose Select Select Map Features and t...

Page 173: ...or use by Internet Explorer and embedding the MapGuideObserver6 class file for use by Netscape 3 Define a function that takes the point from the observers and updates the text boxes with the point s coordinates maps_poi htm Example Code HTML HEAD TITLE Points of Interest Sample TITLE HEAD FRAMESET COLS 75 FRAMESPACING 0 FRAME SRC map htm NAME mapFrame SCROLLING NO MARGINHEIGHT 0 MARGINWIDTH 0 FRAM...

Page 174: ...tizedPoint map point if ver n4 parent poiFrame document pointForm pointLat value point getX parent poiFrame document pointForm pointLon value point getY else parent poiFrame pointForm pointLat value point getX parent poiFrame pointForm pointLon value point getY SCRIPT Embed the map with both the OBJECT tag and the EMBED tag so that it can be used by both browsers OBJECT ID map WIDTH 100 HEIGHT 100...

Page 175: ...toLinkDelay VALUE 20 in actual source EMBED tag is on a single line EMBED SRC http yourserver com maps poi mwf URL http yourserver com maps poi mwf Lat 0 Lon 0 MaScale 0 Width 0 Units M ToolBar On StatusBar On LayersViewWidth 150 DefaultTarget ErrorTarget ObjectLinkTarget ReportTarget URLList Off URLListTarget AutoLinkLayers AutoLinkTarget AutoLinkDelay 20 NAME map WIDTH 100 HEIGHT 100 OBJECT BODY...

Page 176: ...the file doesn t exist sdfToolKit Open c sdf poi sdf 32 2 true if op Add add the point pointLat parseFloat Request Form pointLat pointLon parseFloat Request Form pointLon Set up the variables for building the point A point in the SDF Component Toolkit follows the object hierarchy in shorthand of object geometry segment point Proceed only if the lat and lon values are valid if isNaN pointLat isNaN ...

Page 177: ...the Add command remove the point var sdfObject findObject sdfToolKit pointName if sdfObject null sdfToolKit BeginUpdate sdfToolKit DeleteObject sdfObject sdfToolKit EndUpdate clearVars actionOp UpdateMap Refreshes the map msgText Point removed 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 s...

Page 178: ...ct openSdf objKey The actual search var sdfObject null openSdf BeginKeyIndexSearch objKey sdfObject openSdf SearchToNextObject openSdf EndSearch return sdfObject function clearVars pointName pointLat pointLon op This next section creates the content of the frame H2 Points of Interest H2 HR FORM METHOD POST NAME pointForm TARGET _self ACTION poi asp INPUT TYPE hidden NAME op VALUE None DIV ALIGN le...

Page 179: ...tton WIDTH 50 VALUE Add NAME addPoint WIDTH 50 LANGUAGE JavaScript ONCLICK pointForm op value Add pointForm submit INPUT TYPE button WIDTH 50 VALUE Find NAME findPoint LANGUAGE JavaScript ONCLICK pointForm op value Find pointForm submit INPUT TYPE button WIDTH 50 VALUE Remove NAME removePoint LANGUAGE JavaScript ONCLICK pointForm op value Remove pointForm submit P FORM HR msgText SCRIPT LANGUAGE J...

Page 180: ...Point parent mapFrame document obs else getMap digitizePoint function updateMap Updates the map after an Add or Remove getMap getMapLayer POI setRebuild true getMap refresh function zoomToPoint Zooms to the point after a Find getMap zoomWidth zoomToLat zoomToLon 1000 Mi getMap refresh SCRIPT When the resulting HMTL loads in the browser these last few lines of ASP code call updateMap or zoomToPoint...

Page 181: ... file that contains necessary coordinate information and other attributes for SDF objects and creates an SDF file from it This example is written in Visual Basic Response Write SCRIPT BODY HTML ConvertSDF Example Code VERSION 6 00 Object 3B7C8863 D78F 101B B9B5 04021C009402 1 2 0 RICHTX32 OCX Object F9043C88 F6F2 101A A3C9 08002B2F49FB 1 2 0 comdlg32 ocx Begin VB Form frmLab2 Caption Form1 ClientH...

Page 182: ...ork mapguide water txt Top 120 Width 4212 End Begin VB CommandButton btnExit Caption Exit Height 288 Left 4440 TabIndex 3 Top 3000 Width 1212 End Begin MSComDlg CommonDialog cdOpen Left 4920 Top 2520 _ExtentX 677 _ExtentY 677 _Version 393216 CancelError 1 True DialogTitle Open SDF File Filter SDF Files sdf sdf FilterIndex 1 End Begin VB TextBox txtSdfName Height 288 Left 120 TabIndex 2 Text d work...

Page 183: ...BE35203 8F91 11CE 9DE3 00AA004BB851 Name Courier New Size 7 8 Charset 0 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty End End Attribute VB_Name frmLab2 Attribute VB_GlobalNameSpace False Attribute VB_Creatable False Attribute VB_PredeclaredId True Attribute VB_Exposed False Option Explicit Private Sub btnBrowseSdf_Click On Error GoTo ErrHandler cdOpen Filter SDF Fil...

Page 184: ... edit boxes If txtSdfName Text Or txtTxtName Text Then ShowMessage Select the TXT and SDF files first Exit Sub End If Dim oTlkt As New SdfToolkit Dim oObj As New SdfObject Dim oGeom As New SdfObjectGeometry Dim oSeg As New SdfObjectGeometrySegment Dim oPnt As New SdfDoublePoint Dim strMsg As String Dim strObjType As String strKey As String strName As String strUrl As String strCnt As String Dim X ...

Page 185: ...is segment into the geometry oGeom Add oSeg Put this geometry into the feature If strObjType POLYGON Then oObj SetGeometry sdfPolygonObject oGeom ElseIf strObjType POLYLINE Then oObj SetGeometry sdfPolylineObject oGeom ElseIf strObjType POINT Then oObj SetGeometry sdfPointObject oGeom Else ShowMessage Unknown feature in input file End If Set the feature properties oObj Key Trim strKey oObj Name Tr...

Page 186: ...rst Exit Sub End If Dim Key As String Get the key from Key InputBox Enter the key of the feature to be deleted Key Input Lake If Key Then Exit Sub End If Dim oTlkt As New SdfToolkit Dim oBox As SdfBoundingBox Dim oObj As SdfObject Dim strMsg As String Dim i As Long Dim objFound As Boolean On Error GoTo ErrHandler Open the sdf file in read only mode oTlkt Open txtSdfName Text sdfOpenUpdate Or sdfOp...

Page 187: ...ey was not found If Not objFound Then ShowMessage Feature with specified key not found Else ShowMessage Feature with key Key deleted End If oTlkt Close Exit Sub ErrHandler Display the error number message MsgBox Err Number Err Description Reset the handler before exiting On Error GoTo 0 End Sub Private Sub btnExit_Click End End Sub Sub ShowMessage Msg As String txtMsg Text txtMsg Text Msg vbCrLf E...

Page 188: ...lylineObject GetObjectTypeString POLYPOLYLINE Case sdfPolyPolygonObject GetObjectTypeString POLYPOLYGON End Select End Function SDFInfo Example Code VERSION 6 00 Object 3B7C8863 D78F 101B B9B5 04021C009402 1 2 0 RICHTX32 OCX Object F9043C88 F6F2 101A A3C9 08002B2F49FB 1 2 0 comdlg32 ocx Begin VB Form frmLab1 Caption Form1 ClientHeight 3360 ClientLeft 48 ClientTop 276 ClientWidth 5820 LinkTopic For...

Page 189: ...12 End Begin VB CommandButton btnShowInfo Caption Show Info Height 288 Left 4440 TabIndex 3 Top 720 Width 1212 End Begin MSComDlg CommonDialog cdOpen Left 4920 Top 2280 _ExtentX 677 _ExtentY 677 _Version 393216 CancelError 1 True DialogTitle Open SDF File Filter SDF Files sdf sdf FilterIndex 1 End Begin VB TextBox txtSdfName Height 288 Left 120 TabIndex 2 Text d work mapguide redline sdf Top 120 W...

Page 190: ...51 Name Courier New Size 7 8 Charset 0 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty End End Attribute VB_Name frmLab1 Attribute VB_GlobalNameSpace False Attribute VB_Creatable False Attribute VB_PredeclaredId True Attribute VB_Exposed False Option Explicit Private Sub btnBrowse_Click On Error GoTo ErrHandler Show the open dialog box cdOpen ShowOpen txtSdfName Text ...

Page 191: ...OpenRead True Get SDF name strMsg oTlkt Name ShowMessage SDF File opened strMsg Get description strMsg oTlkt Description ShowMessage Description strMsg Get precision strMsg oTlkt Precision ShowMessage Precision strMsg bit Get key length strMsg oTlkt MaxKeyLength ShowMessage Max Key length strMsg Get version strMsg oTlkt Version ShowMessage Version strMsg Get extents strMsg Min LAT oTlkt BoundingBo...

Page 192: ...Close Exit Sub ErrHandler Display the error number message MsgBox Err Number Err Description Reset the handler before exiting On Error GoTo 0 End Sub Private Sub btnSrchKey_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 Key As String Get the key from Key InputBox Enter the key of the feature Key Input RedLine 144 111...

Page 193: ...howMessage Url oObj Url Set oObj oTlkt SearchToNextObject i i 1 DoEvents Loop If we come here feature with specified key was not found If Not objFound Then ShowMessage Feature with specified key not found Else ShowMessage i 1 features with key Key found End If Close the toolkit oTlkt EndSearch oTlkt Close Exit Sub ErrHandler Display the error number message MsgBox Err Number Err Description Reset ...

Page 194: ...ShowMessage Feature i GetObjectTypeString oObj Type ShowMessage Key oObj Key ShowMessage Name oObj Name ShowMessage Url oObj Url Set oObj oTlkt SearchToNextObject i i 1 DoEvents Wend Close the toolkit oTlkt EndSearch oTlkt Close Exit Sub ErrHandler Display the error number message MsgBox Err Number Err Description Reset the handler before exiting On Error GoTo 0 End Sub Private Sub btnSrchSpat_Cli...

Page 195: ...tialIndexSearch sdfPolylineClass oBox Get first feature Set oObj oTlkt SearchToNextObject i 1 While Not oObj Is Nothing ShowMessage Feature i GetObjectTypeString oObj Type ShowMessage Key oObj Key ShowMessage Name oObj Name ShowMessage Url oObj Url Set oObj oTlkt SearchToNextObject i i 1 DoEvents Wend Close the toolkit oTlkt EndSearch oTlkt Close Exit Sub ErrHandler Display the error number messag...

Page 196: ...ject GetObjectTypeString POLYLINE Case sdfPolyPolylineObject GetObjectTypeString POLYPOLYLINE Case sdfPolyPolygonObject GetObjectTypeString POLYPOLYGON End Select End Function CopySDF Example Code VERSION 6 00 Object 3B7C8863 D78F 101B B9B5 04021C009402 1 2 0 RICHTX32 OCX Object F9043C88 F6F2 101A A3C9 08002B2F49FB 1 2 0 comdlg32 ocx Begin VB Form frmLab2 Caption Form1 ClientHeight 3360 ClientLeft...

Page 197: ...nExit Caption Exit Height 288 Left 4440 TabIndex 3 Top 3000 Width 1212 End Begin MSComDlg CommonDialog cdOpen Left 4920 Top 2520 _ExtentX 677 _ExtentY 677 _Version 393216 CancelError 1 True DialogTitle Open SDF File Filter SDF Files sdf sdf FilterIndex 1 End Begin VB TextBox sdfOutName Height 288 Left 120 TabIndex 2 Text d work mapguide redline1 sdf Top 480 Width 4212 End Begin VB CommandButton bt...

Page 198: ...e 0 False Italic 0 False Strikethrough 0 False EndProperty End End Attribute VB_Name frmLab2 Attribute VB_GlobalNameSpace False Attribute VB_Creatable False Attribute VB_PredeclaredId True Attribute VB_Exposed False Option Explicit Private Sub btnBrowseInSdf_Click On Error GoTo ErrHandler cdOpen Filter Text Files SDF SDF cdOpen FilterIndex 1 cdOpen DialogTitle Open SDF File Show the open dialog bo...

Page 199: ... first Exit Sub End If Dim oTlktIn As New SdfToolkit Dim oTlktOut As New SdfToolkit Dim oObj As SdfObject Dim oBox As New SdfBoundingBox Dim xMin As Double yMin As Double xMax As Double yMax As Double Dim i As Long On Error GoTo ErrHandler Open the input sdf file in readonly mode oTlktIn Open sdfInName sdfOpenRead True Open the output sdf file for write append mode oTlktOut Open sdfOutName sdfOpen...

Page 200: ...ot oObj Is Nothing oTlktOut AddObject oObj i i 1 Set oObj oTlktIn SearchToNextObject Loop Wind up oTlktIn EndSearch oTlktOut EndUpdate oTlktIn Close oTlktOut Close ShowMessage sdfInName Text copied to sdfOutName Text ShowMessage Total features written i Exit Sub ErrHandler Display the error number message MsgBox Err Number Err Description Reset the handler before exiting On Error GoTo 0 End Sub Pr...

Page 201: ...e Case sdfPointObject GetObjectTypeString POINT Case sdfPolygonObject GetObjectTypeString POLYGON Case sdfPolylineObject GetObjectTypeString POLYLINE Case sdfPolyPolylineObject GetObjectTypeString POLYPOLYLINE Case sdfPolyPolygonObject GetObjectTypeString POLYPOLYGON End Select End Function CopySDF Example Code continued ...

Page 202: ...202 ...

Page 203: ...plication examples DWG filtering 164 facilities management 156 municipal 140 redlining 136 SDF Component Toolkit 171 72 181 188 196 applications 11 136 advanced 15 as Java wrapper for Java Edition 38 creating 15 17 debugging 48 simple 15 stand alone 19 argument type checking 48 ASP See Active Server Pages attribute data displaying for selected features reports 85 86 listing with ColdFusion 89 92 u...

Page 204: ...Ns working with 90 102 112 116 125 See also OLE DB DWG 8 164 application examples 164 DWG layer defined 165 DWG map layer defined 165 DWG continued filtering layers 164 MapGuide map layer defined 165 Dynamic Authoring Toolkit 10 E embedding Java Edition in an HTML page 35 map 18 for ActiveX Control 22 for Java Edition 24 35 for Plug In 22 in frame 23 MWFs in HTML pages 20 enabling print events 66 ...

Page 205: ...aying the map in 24 embedding Java Edition in an HTML page 35 embedding maps 35 installing on client machine 29 Java applet wrapper for 24 38 Java application wrapper for 38 Java peer applet for 38 map access 35 from HTML 35 from Java 38 from JavaScript JScript 35 platform requirements 9 required software 25 39 Viewer differences 39 Java Server Pages JSP 26 JavaScript 10 36 78 accessing from an ap...

Page 206: ... 71 menus adding items to 108 132 MGDwgDataSources 8 165 MGError 47 48 MGMapObject 50 Microsoft Internet Explorer See Internet Explorer mode of map 9 municipal application example 140 MWF 13 20 165 N Netscape Navigator embedding a map 22 event handling 71 event observers in 70 JavaScript support in 36 map access 32 new features 8 DWG support 8 Java Edition platform support changes 9 map mode retri...

Page 207: ... of Autodesk MapGuide Server 43 of data 43 of Viewer API 43 server side scripts and applications 85 86 setting events for event observers 71 Solaris supported configurations 19 Spatial Data Files SDFs See SDF Component Toolkit Spatial Index Files SIFs See SDF Component Toolkit stand alone application 19 supported configurations 18 symbols adding to a printout 64 bitmap support 8 U updating data vi...

Page 208: ...Index 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 ...

Reviews: