Solution
To design web pages so that the Autodesk MapGuide® ActiveX control does not need to be activated by a user, you should use the technique described in the MSDN article, Activating ActiveX Controls.
The code sample below shows how use the technique with the MapGuide ActiveX Control. The typical way to embed the control is to add object tags directly to the web page.
<HTML>
<BODY>
<OBJECT ID="map" WIDTH=100% HEIGHT=100%
CLASSID="CLSID:62789780-B744-11D0-986B-00609731A21D"
CODEBASE="ftp://ftp.autodesk.com/pub/mapguide/viewer/mgaxctrl.cab#Version=6,0,0,0">
<PARAM NAME="URL" VALUE="http://www.mapguide.com/maps/world.mwf?LAT=0.0&LON=0.0&SCALE=20000000">
<EMBED SRC="http://www.mapguide.com/maps/world.mwf?LAT=0.0&LON=0.0&SCALE=20000000"
BORDER="0" WIDTH=100% HEIGHT=100%
NAME="map" TYPE="application/x-mwf">
</OBJECT>
</BODY>
</HTML>
When you use the external MGObject.js script shown below, the code is rewritten as follows:
<HTML>
<script src="MGObject.js"></script>
<BODY>
<script>
InsertControl("http://www.mapguide.com/maps/world.mwf",0.0,0.0,20000000);
</script>
</BODY>
</HTML>
The external MGObject.js script contains the InsertControl function which is used to write the object element into the web page as shown below.
// InsertControl writes the HTML used to display the ActiveX Control.
// The parameters are the URL of the map to be displayed, the center
// latitude and longitude values, and the // initial scale.
function InsertControl(url, lat, lon, scale)
{
document.writeln('<OBJECT ID="map" WIDTH=100% HEIGHT=100%');
document.writeln(' CLASSID="CLSID:62789780-B744-11D0-986B-00609731A21D"');
document.writeln(' CODEBASE="ftp://ftp.autodesk.com/pub/mapguide/viewer/mgaxctrl.cab#Version=6,0,0,0">');
document.writeln(' <PARAM NAME="URL" VALUE="' + url + '?LAT=' + lat + '&LON=' + lon + '&SCALE=' + scale + '">');
document.writeln(' <EMBED SRC="' + url + '?LAT=' + lat + '&LON=' + lon + '&SCALE=' + scale + '"');
document.writeln(' BORDER="0" WIDTH=100% HEIGHT=100%');
document.writeln(' NAME="map" TYPE="application/x-mwf">');
document.writeln('</OBJECT>');
}
When you use a function to write the HTML code, it is possible to create a generic function that can be reused for multiple web pages on a site. As a result, you will reduce the number of external scripts that need to be created.
Warning: If you clear the Disable Script Debugging (Internet Explorer) option on the Advanced Tab of the Internet Options Control Panel, controls created using these techniques will still require activation.
Give us your feedback on this document:
AUTODESK DOES NOT GUARANTEE THAT YOU WILL BE ABLE TO SUCCESSFULLY DOWNLOAD OR IMPLEMENT ANY SERVICE PACK OR WORKAROUND, OR ANY OF THE TIPS, TRICKS, EXAMPLES OR SUGGESTIONS OUTLINED IN ANY AUTODESK PRODUCT SUPPORT TECHNICAL DOCUMENTS. TECHNICAL DOCUMENTS, SERVICE PACKS AND WORKAROUNDS ARE SUBJECT TO CHANGE WITHOUT NOTICE TO YOU. AUTODESK PROVIDES TECHNICAL DOCUMENTS, SERVICE PACKS AND WORKAROUNDS "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL AUTODESK OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF DATA, OR LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, THAT MAY OCCUR AS A RESULT OF IMPLEMENTING ANY SERVICE PACK OR WORKAROUND, OR ANY SUGGESTION OUTLINED IN ANY AUTODESK PRODUCT SUPPORT TECHNICAL DOCUMENT, EVEN IF AUTODESK OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.