102

I am working on Google Maps Javascript API V 3.

Everything is working fine but I want to disable the MAP button which appears in the top right area with SATELLITE button.

How can I do this?

jarrodwhitley
  • 826
  • 10
  • 29
Jatin Dhoot
  • 4,294
  • 9
  • 39
  • 59

7 Answers7

143
var myOptions = {
    zoom: 2,
    center: **Your LatLng object**,
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID]
    }, // here´s the array of controls
    disableDefaultUI: true, // a way to quickly hide all controls
    mapTypeControl: true,
    scaleControl: true,
    zoomControl: true,
    zoomControlOptions: {
      style: google.maps.ZoomControlStyle.LARGE 
    },
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); // displays in <article id="map_canvas"></article>
//map.mapTypeControl = false; // OPTIONAL: hides the map control
Ikar Pohorský
  • 4,617
  • 6
  • 39
  • 56
blomman9
  • 1,594
  • 2
  • 9
  • 7
69

When you enable the map and passes the options to it, you have the chance to specify a mapTypeControlOptions. These have an Array that specifies what kind of maptype's you will allow the user to be able to see. It can be seen here http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeControlOptions.

If you don't want the user to have any options as to the maptypes, you can also specify that by setting the maps mapTypeControl to false.

Kasper Vesth
  • 4,103
  • 1
  • 37
  • 31
  • 2
    Setting mapTypeControl to false definitely vanishes the control but how can I customize it so that mapTypeControl only contains SATELLITE and TERRAIN buttons? – Jatin Dhoot May 12 '11 at 11:20
  • That is what the mapTypeControlOptions should do.. It holds an array where you can specify that SATELLITE and TERRAIN are the options the user should see. – Kasper Vesth May 12 '11 at 11:33
  • 27
    I don't know if it's a v3 thing, but if someone wishes to completly hide this control, setting `mapTypeControl` to `false` doesn't work. Instead what worked for me (in v3) was setting: `mapTypeControlOptions: { mapTypeIds: [] }` – OrPo Mar 06 '14 at 11:54
64

Disable Satellite option:

mapTypeControl: false

Disable street view.

streetViewControl: false
PodTech.io
  • 4,874
  • 41
  • 24
21

mapTypeControl and streetViewControl option to false

 var map = new google.maps.Map(document.getElementById('map_canvas'), {
             center: new google.maps.LatLng(latitudeFirst, longitudeFirst),
             zoom: 12,
             streetViewControl: false,
             mapTypeControl: false
        });  
Surendra Kumar Ahir
  • 1,609
  • 18
  • 19
20

You can hide them via css

.gm-style-mtc {
  display: none;
}
webchun
  • 1,204
  • 2
  • 13
  • 30
3

I had the same issue. Setting mapTypeControl: false and passing with other options worked for me. You may check spec here.

Khrystyna Skvarok
  • 1,198
  • 13
  • 15
1

You can achieve this in two ways:

  1. JS

    streetViewControl: false,
    
  2. CSS

    .gm-style-mtc {
      display: none;
    }
    
m4n0
  • 29,823
  • 27
  • 76
  • 89
Ahmed Ali
  • 11
  • 1