Autodesk 15606-011408-9300 Developer Guide - Page 50
Overview, Working with Map Layers, Counting Map Layers
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 50 highlights
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 as functions, reserving the term method for the Autodesk MapGuide Viewer API. Also note that although spatial data on the map consists of map features, the methods and properties in the Autodesk MapGuide Viewer API that work with map features use the term object instead of feature. This difference in terminology exists because map features were called map objects in previous releases 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 Layers The countLayers function counts the layers in a map and displays the count in a dialog box: function countLayers() { var map = getMap(); var layers = map.getMapLayersEx(); var cnt = layers.size(); alert("This map has " + cnt + " layer(s)."); } The function starts by calling the getMap function and assigning its return value to a variable called map: var map = getMap(); Remember that getMap is a custom function that detects the user's browser type and returns an MGMap object using the syntax required by that browser (see page "Map Access for ActiveX Control and Plug-In" on page 32). 50 | Chapter 4 Working with Map Layers, Map Features, and Printing