14.01.2013 Views

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

page, then emit a function containing the correct parameters. Use this<br />

technique when you want the Viewer to change when the page loads.<br />

■ Execute the JavaScript inside the script frame. Use this technique when<br />

you want the Viewer to change as a result of an action in the Map<strong>Guide</strong><br />

page, without reloading the page.<br />

■ Call the Viewer API during client-side interaction with the page or using<br />

the Invoke Script command type in the web layout. Use this technique<br />

when you want to call the API directly from the tool bar.<br />

NOTE It is important to know the relationships between the frames. Pages in the<br />

task area must refer to parent.parent.mapFrame in order to traverse the frame<br />

hierarchy properly. However, if the same function executes from the script frame<br />

or the task bar, it only needs to refer to parent.mapFrame, because the script<br />

frame and the map frame are part of the same frame set.<br />

Many Viewer API calls will generate requests to the site server, either to refresh<br />

data in the Viewer or to notify the site server of a change in Viewer state.<br />

These requests are generated automatically.<br />

Calling the Viewer API from the Task Pane<br />

Use this technique when you want the Viewer API calls to be made when the<br />

page loads. For example, if you have a task in the task list that zooms the map<br />

to a pre-defined location, then you do not need any user input. The Viewer<br />

should zoom as soon as the page loads.<br />

The map frame contains a JavaScript function to center the map to a given<br />

coordinate at a given map scale. To call this function from a page loading in<br />

the task pane, create a function that will be executed when the onLoad event<br />

occurs. The following is a simple example. If you add this to the task list and<br />

select the task, the displayed map will reposition to the given location.<br />

14 | Chapter 1 Introduction

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!