如何禁用谷歌地图的卫星视图?

我正在研究 Google Maps Javascript API V3。

一切工作正常,但我想禁用的 MAP 按钮,出现在右上方的区域与卫星按钮。

我怎么能这么做?

113704 次浏览

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.

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

You can hide them via css

.gm-style-mtc {
display: none;
}

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

Disable Satellite option:

mapTypeControl: false

Disable street view.

streetViewControl: false

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
});

You can achieve this in two ways:

  1. JS

    streetViewControl: false,
    
  2. .gm-style-mtc {
    display: none;
    }