MapGuide Viewer API Reference.
The MapGuide Viewer API is a set of JavaScript functions used to interact with the Viewer. Many of the Viewer frames contain embedded JavaScript functions that can be called from other locations. For full details about the available functions, refer to the onlineTo execute any of the Viewer API functions, call them from JavaScript embedded in a page. There are three common techniques for this:
It is important to know the relationships between the frames. JavaScript executes in the context of a single frame, but it can call functions from other frames by locating them in the frame hierarchy. The following frames are children of the main Viewer frame:
taskPaneFrame is a child of the taskFrame.
TheCustom JavaScript code can execute in the context of the main frame, the script frame, or the task pane frame.
ZoomToView() function of the mapFrame from the main frame:
JavaScript defined as an Invoke Script command executes in the context of the main frame. To execute functions in one of the other frames, identify the function with the frame name and function name. For example, the following calls themapFrame.ZoomToView(xLoc, yLoc, newScale, true);
scriptFrame must go up 1 level in the hierarchy using parent. For example:
JavaScript loaded into theparent.mapFrame.ZoomToView(xLoc, yLoc, newScale, true);
taskPaneFrame must go up 2 levels in the hierarchy using parent.parent. For example:
JavaScript loaded into theparent.parent.mapFrame.ZoomToView(xLoc, yLoc, newScale, true);
Many Viewer API calls will generate requests to the site server, either to refresh data in the Viewer or to notify the site server of a change in Viewer state. These requests are generated automatically.