This class provides methods to fetch ads from the Lat49 server. In most cases, the publisher would not use this class directly, and would instead use the higher-level Lat49.AdHelper class.
Functions in class Lat49.Ads:
| Lat49.Ads(publisherID); | ||
The constructor for the Lat49.Ads class. publisherID is the publisher account ID. | ||
| requestAd(x, y, z, args); | ||
Requests the ad for the tile with indices (x,y) at zoom level z. This method works asynchronously, wrapping the ad when it is ready in a DIV and passing it to a callback function. The name of the callback function should be placed in an associative array with a key of 'callback', and the array passed to this method via the args parameter. For example, if getAdCB(adDiv) is the function that handles the returned DIV, then args would be set to: {callback:getAdCB}. | ||
The following example produces similar output to Example 3-5, except that it uses the low-level API rather than the default Lat49.AdHelper object to display the ad. Note that the Lat49.fetchCSS() function is called explicitly after the body is loaded because the Lat49.initAds() function is not used here.
Example 4-1. Low Level Request Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Lat49LowLevelTest</title>
<META NAME="description" CONTENT="A web site that tests the low level Lat49 API.">
<!-- Include the Lat49 API script. -->
<script type='text/javascript'
src='http://adserver.lat49.com/lat49/v0.10/lat49.js'>
</script>
<script type='text/javascript'>
lowLevelRequest = function() {
var publisherID = '12345'; //This is a fake ID.
var ads = new Lat49.Ads(publisherID);
ads.requestAd(0,0,16,{callback:lowLevelCB});
}
//This is the callback that handles the ad when it's ready.
lowLevelCB = function(adDiv) {
var displayDiv = document.getElementById("adcontainer");
displayDiv.appendChild(adDiv);
}
</script>
</head>
<!-- Fetch the ad CSS script on loading the body. -->
<body onload="javascript:Lat49.fetchCSS()">
<h2> Simple Low Level Lat49 test. </h2>
<p>
<!-- Fetch the ad when the link is clicked. -->
Click the <a href="javascript:lowLevelRequest()">link</a>
to see the ad for tile (0,0,16):
</p>
<div id="adcontainer" style="width:242px; height:133px; position:relative"></div>
</body>
</html>
|