Google Maps JavaScript API v3 AdSense Library Demonstration

This page explains the steps that can be used in order to embed a Google Map on the Desktop of your Windows XP computer.

Description

Google Maps JavaScript API v3 AdSense Library demonstration allows you to see how it works and what it looks like to the end-user.

The Maps Ad Unit in the Google Maps JavaScript API allows you to put display advertising on a map to monetize your Google Maps API application. The Maps Ad Unit will be turned off on November 2, 2015. You can use AdSense ad units instead.

Migrating from a Google Maps JavaScript API ad unit to an AdSense ad unit

How it Works


var map;
var geocoder;

var ad = '<ins class="adsbygoogle" style="display:inline-block;width:320px;height:100px" data-ad-client="ca-pub-XXXXXXXXXXX" data-ad-slot="YYYYYYYYY"></ins>';

function initialize() {
var monterey = new google.maps.LatLng(41.38087,2.122802);
var mapOptions = {
center: monterey,
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU}
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

var adNode = document.createElement('div');
adNode.innerHTML = ad;
// You can use another ControlPosition if you wish.
map.controls[google.maps.ControlPosition.TOP_CENTER].push(adNode);
google.maps.event.addListenerOnce(map, 'tilesloaded', function()
{
(adsbygoogle = window.adsbygoogle || []).push({});
});
}

Relevant Links

http://www.google.com/apis/maps/

Version History

Version Date Description
Version 1.0 09/02/2008 First Version
Version 2.0 09/11/2013 Implemented Google Maps V3 and Google Maps JavaScript API v3 AdSense Library
Version 3.0 11/05/2015 Implemented AdSense ad unit

Comments For This Page

Not seeing the ads in the map either.
On 9th March 2011
i dont see any ads other then ads at bottom. can you please check on this and see why its not showing ads on map!!!
By Basit on 8th February 2010
Wow, that must be totally unprofitable! When do we get a text ad strip on the bottom of the map like in Google Maps?
On 30th December 2008

Add your own comment below and let others know what you think: