Follow us on Facebook

How to Monetize Google Maps on your Website with AdSense Ads

You have been using Google AdSense ads to monetize the content of your website but did you know that you can also use the same AdSense program to also monetize any Google Maps that are embedded on your web pages. You can embed a Google Map and AdSense ads will be automatically served inside the map that will either be contextually relevant to the content of the page or targeted based on the location of the visitors.

The Google Maps block embedded below contains a rectangular AdSense ad unit placed near the top-center area of the map. Where Am I is another example of a website that embeds Google Maps with ads.

AdSense Ads for Embedded Google Maps

Google Maps offers you an easy option to embed maps onto your website but the default embed code does not allow monetization. You’ll have build the map on your own using the Google Maps API to enable advertising and this isn’t difficult either. Let me show you in few easy step.
To get started, go to the Google AdSense website and create a new ad unit. You can choose the default color scheme for the ad unit (white background) and pick responsive for the size. The latter doesn’t matter though as the ad unit will automatically fit inside the container map.
Next, copy-paste the following Google Maps embed code anywhere in your web template.
  1. <div id="google-maps" style="width:500px; height:500px;"></div>
  3. <script src="">
  4. </script>
  5. <script src="//">
  6. </script>
  8. <script>
  10. function showGoogleMaps() {
  12. var mapOptions = {
  13. center: new google.maps.LatLng(38.8977, -77.036),
  14. zoom: 5
  15. };
  17. var map = new google.maps.Map(
  18. document.getElementById('google-maps'), mapOptions);
  20. var ad = '<ins class="adsbygoogle" \
  21. style="display:inline-block;width:300px;height:100px" \
  22. data-ad-client="ca-pub-xxxx" \
  23. data-ad-slot="yyyy"></ins>';
  25. var adNode = document.createElement('div');
  26. adNode.innerHTML = ad;
  28. map.controls[google.maps.ControlPosition.TOP_CENTER].push(adNode);
  30. google.maps.event.addListenerOnce(map, 'tilesloaded', function() {
  31. (adsbygoogle = window.adsbygoogle || []).push({});
  32. });
  34. }
  36. google.maps.event.addDomListener(window, 'load', showGoogleMaps);
  38. </script>
You can replace the height and width of the Google Maps in line #1 to fit your website layout while the latitude and longitude of the place needs to be replaced in line #11. Finally, xxxx and yyyy in the embed code should be replaced with your AdSense Publisher ID and the Ad Slot ID respectively. You can find these values in the embed code generated by AdSense.
If you are ready to fiddle with the JavaScript, you can even more option to customize the embedded map.
Google Maps with AdSense Ads
For instance, you can easily change the position of the AdSense ad unit inside Google Maps from TOP_CENTER (line #28) to BOTTOM_CENTER or something else.
Similarly, you can change the default view of the embedded map from Roadmap to Satellite or Hybrid. The various controls inside the Google map – like the street view Pegman, the zoom slider, the pan control – can be easily hidden or moved to a different position by setting the corresponding properties inside the mapOptions object.
Also see: Embed Google Maps Street View
  1. <script>
  3. var mapOptions = {
  5. // Center the map on this address
  6. center: new google.maps.LatLng(38.8977, -77.036),
  8. // Set the initial zoom level
  9. zoom: 14,
  11. // Hide the slider to control the zoom levels
  12. zoomControl: false,
  14. // Hide the controls to pan the map
  15. panControl: false,
  17. // Display the street view peg but in a different position
  18. streetViewControl: true,
  19. streetViewControlOptions: {
  20. position: google.maps.ControlPosition.BOTTOM_CENTER
  21. },
  23. // Allow visit to switch to Satellite view and back
  24. mapTypeControl: true,
  26. // Set the default type of the map to Roadmap
  27. mapTypeId: google.maps.MapTypeId.ROADMAP
  29. };
  31. </script>
Share on Google Plus

About Naresh Sahu

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment


Post a Comment

Blog Archive