Skip to content

Add Google Adsense to Google Maps

willywg edited this page Feb 24, 2012 · 2 revisions

1. Load Adsense Library

<%= gmaps({
          ...
          "map_options" => {"libraries" => ["adsense"] },
          ...
          })
 %>

2. Call Adsense with Javascript

Gmaps.map.callback = function() {
      var adUnitDiv, adUnitOptions;
      adUnitDiv = document.createElement("div");
      adUnitOptions = {
        format: google.maps.adsense.AdFormat.HALF_BANNER,
        position: google.maps.ControlPosition.RIGHT_BOTTOM,
        map: Gmaps.map.map,
        visible: true,
        publisherId: "ca-pub-3964215240206120"
      };
      new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions);
    };

Documentation: http://code.google.com/intl/en/apis/maps/documentation/javascript/advertising.html