Autodesk 15607-010000-5000A Manuale Utente

Pagina di 180
74
|
Chapter 6
Using Buzzsaw with Autodesk MapGuide Viewer
Appendix: Buzzsaw Code Integration
The following code sample illustrates how to integrate Autodesk MapGuide 
and Buzzsaw so that you can avoid the need to authenticate the Buzzsaw 
interface, retain the current map state, and prevent the non-secure site 
warning message from appearing. See the preceding section for more infor-
mation about managing these three elements of the interface.
Note  The URL parameters to the OBJECT tag have to be specified before the 
sample will work. Also, the CODEBASE parameter to the OBJECT tag should be 
either specified or removed. The cookieNameXXX variables can be changed to 
give unique cookie names for multiple MapGuide applications stored in Buzzsaw.
<HTML>
<HEAD>
<TITLE>MapGuide Buzzsaw Integration</TITLE>
</HEAD>
<SCRIPT LANGUAGE="VBScript">
Sub map_onMapLoaded(map)
    onMapLoaded map
End Sub
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
// The following variables identify the names of the cookies used.
var cookieNameMapStateLayers = "mapStateLayers";
var cookieNameMapStateGroups = "mapStateGroups";
var cookieNameMapStateURLParam = "mapStateURLParam";
// When the map is initially loaded this event handler is called.
// This event is used to turn on any layers that were on when the map was ///
// previously loaded.
function onMapLoaded(map) {
    if (map != null) {
        var layerVisibility = getCookie(cookieNameMapStateLayers);
        if (layerVisibility != null) {
            var layers = map.getMapLayersEx();
            for (var i = 0; i < layers.size(); i++) {
       
        
 if (isNameIn(layerVisibility,escape(layers.item(i).getName()))) {
                    layers.item(i).setVisibility(true);
                } else {
                    layers.item(i).setVisibility(false);
                }
            }
        }
        var groupVisibility = getCookie(cookieNameMapStateGroups);
        if (groupVisibility != null) {
            var layerGroups = map.getMapLayerGroups();
            for (var i = 0; i < layerGroups.size(); i++) {
                if (isNameIn(groupVisibility, escape(layerGroups.item(i).getName()))){