3.3. Getting ads

Once a Lat49.AdHelper object has been created (either directly or via the Lat49.initAds() method), then ads can be fetched and displayed via the updateAdByLatLon() method. The parameters to the method are the ID of the DIV to which the ad is appended as a child, and the latitude, longitude and zoom level of interest.

N.B. It is recommended that the DIV containing the ads be created just for that task, and not contain other elements in addition to the ads. The ad contents can be as large as 242x133 pixels. If embedding the ads within HTML pages, the width and height properties of the DIV's style should be set to provide space for the ads within the page layout (otherwise, the ads will overlay other elements in the page). However, when embedding ads within a map, the width and height properties should be left out, otherwise the ad DIV will interfere with some of the mouse interactions on the map.

The updateAdByLatLon() method is available through either the Lat49.AdHelper class or the Lat49 object. The following example shows some HTML code for displaying an ad using the Lat49 method:

Example 3-4. Displaying an ad

  <p>
    <!-- Fetch the ad when the link is clicked and display it in the following DIV. -->
    Click the <a href="javascript:Lat49.updateAdByLatLon('adcontainer',49.0,-123.0,16)">
    link</a> to see the ad for 123.0W, 49.0N and zoom level 16:
  </p>

  <div id="adcontainer" style="width:242px; height:133px; position:relative"></div>

More information about the updateAdByLatLon method can be found in Section 4.2, and about zoom levels in Section 2.1. There are also Lat49 specific attributes that can be added to the ad containing DIV that change the behaviour of the ads (as described in Section 4.5). In particular, Section 4.5.1 describes an attribute for ad positioning that may have an impact on HTML page layout.