View this example full screen.
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(36.5987, -121.8950),
zoom: 12
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var adUnitDiv = document.createElement('div');
// Note: replace the publisher ID noted here with your own
// publisher ID.
var adUnitOptions = {
format: google.maps.adsense.AdFormat.HALF_BANNER,
position: google.maps.ControlPosition.TOP_CENTER,
publisherId: 'ca-google-maps_apidocs',
map: map,
visible: true
};
var adUnit = new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
<!DOCTYPE html>
<html>
<head>
<title>Map Ad Unit</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=adsense"></script>
<script>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(36.5987, -121.8950),
zoom: 12
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var adUnitDiv = document.createElement('div');
// Note: replace the publisher ID noted here with your own
// publisher ID.
var adUnitOptions = {
format: google.maps.adsense.AdFormat.HALF_BANNER,
position: google.maps.ControlPosition.TOP_CENTER,
publisherId: 'ca-google-maps_apidocs',
map: map,
visible: true
};
var adUnit = new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>