Change map types from outside links

Description

"setMapTypeId()" methods of Map class is used to change the map type. You can set one of maptype of these:

google.maps.MapTypeId.ROADMAPThis map type displays a normal street map.
google.maps.MapTypeId.SATELLITEThis map type displays satellite images.
google.maps.MapTypeId.HYBRIDThis map type displays a transparent layer of major streets on satellite images.
google.maps.MapTypeId.TERRAINThis map type displays maps with physical features such as terrain and vegetation.
Below is basic way.
  mapCanvas.setMapTypeId(google.maps.MapTypeId.TERRAIN);




Code

<script type='text/javascript'>

    var mapCanvas;
    function initialize() {
      var latlng = new google.maps.LatLng(40.7711329, -73.9741874);
      var myOptions = {
        zoom: 4,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      mapCanvas = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    }
    function changeMapType(mapTypeId) {
      mapCanvas.setMapTypeId(google.maps.MapTypeId[mapTypeId]);
    }
    google.maps.event.addDomListener(window, "load", initialize);
  </script>

Search
Books
Google Maps API Programming Guide

Four Google Maps API Experts wrote this book. Introducing useful examples for developers!
See more details