Map Access for ActiveX Control and Plug-In
|
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:
<SCRIPT LANGUAGE="JavaScript">
function getMap()
{
if (navigator.appName() == "Netscape")
return document.map;
else
return window.map;
}
</SCRIPT>
If your application had multiple HTML frames, the code to access the same
map in a frame called
Left
would look like this:
<SCRIPT LANGUAGE="JavaScript">
function getMap()
{
if (navigator.appName == "Netscape")
return parent.Left.document.map;
else
return parent.Left.map;
}
</SCRIPT>
Note
We chose the name
getMap
for our function, but the name can be any-
thing 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 variable:
var map = getMap();
You can then apply methods to that variable to work with the map. For
example, the following function displays an Autodesk MapGuide report
called
Parcel Data
:
function runReport()
{
var jb_map = getMap();
// assign map to variable
jb_map.viewReport('Parcel Data');
// call method from variable
}
Or you could bypass the variable assignment and use
getMap
directly:
function runReport()
{
getMap().viewReport('Parcels'); // use getMap() return value
}
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 6: ...vi ...
Page 16: ...16 ...
Page 30: ...30 ...
Page 84: ...84 ...
Page 134: ...134 ...
Page 202: ...202 ...