How to Add Adsense into Your Google Map API Application

There are two Adsense for Maps products  provided by Google to monetize Google Maps API application:

  • Advertising alongside local bussines search result using the GoogleBar that requires your Adsense account be enabled for Adsense for Search
  • Advertising based on map viewport using the Maps Ad Unit that requires your AdSense account be enabled for Adsense for Content.

Advertising using the GoogleBar

Adsense using the GoogleBar

Adsense using the GoogleBar

var map;
if (GBrowserIsCompatible()) {
    var mapOptions = {
         googleBarOptions : {
                 style : 'new',
                 adsOptions: {
                      client: 'your-publisher-id',
                      channel: 'your-ads-channel-id',
                      adsafe: 'high',
                      language: 'en'

    map = new GMap2(document.getElementById('map'), mapOptions);
    map.setCenter(new GLatLng(27.6648274, -81.5157535), 12);

Line 06: adsense options:
Line 07: your adsense publisher ID
Line 08: your adsense for search channel (optional)
Line 09: ad safety level (optional)
Line 10: language in which to display results

Advertising using the Maps Ad Unit

Adsense using Maps Ad Unit

Adsense using Maps Ad Unit

var adsManagerOptions = {
  maxAdsOnMap : 2,
  style: 'your-ads-unit',
  channel: 'your-ads-channel-id'

var publisherID = 'your-publisher-ID';

adsManager = new GAdsManager(map, publisherID, adsManagerOptions);

Line 01: specify ads options
Line 02: maximum number of ads
Line 03: your ads unit
Line 04: your ads channel id
Line 07: specify your publisher id
Line 09: construct the  GAdsManager object
Line 10: enable ads

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather


  1. Richard says

    I am currently making a website. I am very new to all this! this actually makes no sense? what do I actually do with this code????


Leave a Reply

Your email address will not be published. Required fields are marked *