//****************************************************************************** // MapGuide API code to be executed first when API functions are needed // at map initial load time. // - Gets the map object // - Does map initialization: // Sets the legend width // Turns off all the print Page Setup options. // - Waits for map not busy // - Invokes the setUpMap() function which must be separately included to do // the real work. If no further setup is needed, then there must be // a null setUpMap function defined. // // Typically used with the scriptpath mgmap.cfm parameter pointing to a file // containing a // // // or if there is no further setup processing desired: // // // // // Now invoked by the Wrapper's map tag online parameter value as specified // by the onload JavaScript variable defined below. // Used to be invoked by ADDING the something like this the MapGuide map URL: // &scriptpath=/myapp/mapguideAPI.inc&onload=javascript%3AmapInit%28%29 //****************************************************************************** //****************************************************************************** // Specify code to run in the map tag onload operand. The "Wrapper" // looks for an onload variable and uses it in the onload operand. // We use onload to start the map initialization process with the API. //****************************************************************************** var onload = 'javascript:mapInit()'; //****************************************************************************** // getMap: Retrieves the map object. //****************************************************************************** function getMap() { if (viewertype == 'plugin') // If mgmapframe.cfm says it embedded a Netscape 4.x plugin map, then return document.mgmapspan.document.embeds[0]; // Use embeds to get the object instead of the myMap embed name because the // name cannot be found with our use of the span tag for some unknown reason. else // If we're not using the plugin (i.e. ActiveX control or Java Viewer), then return myMap; } //****************************************************************************** // mapInit: // This function is the first function invoked and typically specified by the // mgmap.cfm onload parameter. mapInit gets the map, tweaks the map, // and invokes mapInit2 to wait for map not busy and call the user's setUpMap function. //****************************************************************************** function mapInit() { map = getMap(); map.setAutoRefresh(false); // Don't refresh the map while we tweak it. map.statusBar = "On"; // Why is this needed? The status bar should be on by default. map.LayersViewWidth = 250; // Make the legend wider. This causes map busy. // Turn off all the optional things in the Page Setup for printing. pageSetup = map.getPageSetup(); pageSetup.setInclude("mg_title", false); pageSetup.setInclude("mg_legend", false); pageSetup.setInclude("mg_scalebar", false); pageSetup.setInclude("mg_northarrow", false); pageSetup.setInclude("mg_url", false); pageSetup.setInclude("mg_timestamp", false); map.setAutoRefresh(true); // Now that we're done tweaking the map, allow refresh. mapInit2(); // Wait for map not busy and then invoke setUpMap. } //****************************************************************************** // mapInit2: // This function is the second and last function invoked. // It waits for map not-busy, and then invokes setUpMap() to do more. //****************************************************************************** function mapInit2() { map = getMap(); if (map.isBusy()) var wait = setTimeout("mapInit2()",100); else setUpMap(); // Move on to the real setup work. }