Advertisers may provide business locations that can be accessed and displayed as pushpins if requested by the viewer. The locations are returned via callbacks when the viewer clicks on buttons in the pushpin control panel. The publisher must provide the callbacks for showing and hiding the pushpins. Examples for Google and Virtual Earth maps are given later in this document.
Lat49 ads may include one or more latitude longitude pairs. These pairs can be retrieved for each ad and used to display the locations of the pushpins on a map. In order to access the ad's pushpin data, two attributes must be included in the ad DIV: onlat49pushpin, and onlat49hidepushpin.
When the onlat49pushpin and onlat49hidepushpin attributes are defined, the Lat49 ad server knows that you wish to implement the pushpin feature. As a result, the ads returned include a control panel with two buttons: 'Map it' and 'Clear'. The 'Map it' button is only enabled if the ad displayed has pushpin data.
The onlat49pushpin and onlat49hidepushpin attributes specify the callback function used when the user clicks on 'Map it" and 'Clear' respectively.
Example 3-6. Setting up the pushpin attributes
<p>
<!-- Fetch the ad and the ad control panel 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>
<!-- View Pushpin Control Panel with Ad -->
<div id="adcontainer" onlat49pushpin="showPushPin" onlat49hidepushpin="hidePushPin"
style="width:242px; height:133px; position:relative"></div> |
The callback method associated with the onlat49pushpin attribute is where you insert code to display pushpins over a map. The method should provide an argument that will be filled with pushpin data: latitude, longitude, title, address, and the url for the pushpin graphic.
Example 3-7. The showPushpin callback method
/* Write code here to display pushpins related to the displayed ad. */
/* Parameter loc will be filled pushpin data in order of closest to furthest.*/
function showPushPin(loc)
{
var i=0;
var pushpindata = "";
for(i=0; i<loc.length;i++)
{
pushpindata = pushpindata+"latitude="+loc[i].lat+" ";
pushpindata = pushpindata+"longitude="+loc[i].lon+" ";
pushpindata = pushpindata+"title="+loc[i].title+" ";
pushpindata = pushpindata+"address="+loc[i].address+"\n\n";
pushpindata = pushpindata+"pinurl="+loc[i].pinurl+"\n\n";
}
alert(pushpindata);
} |
The callback method associated with the onlat49hidepushpin attribute is where you insert code to hide all the Lat49 ad related pushpins.