Remove Satellite and Terrain tab from Google Map

Normally when we create Google map it automatically shows two tabs on the google map.Below are the example of the normal google map.

google map

Below are the code that produce above map

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
map.setUIToDefault();
}
}

Now to remove satellite and Terrain tab you need to modify above code like below

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
/*
Simply comment below line this will remove all three tabs as well as controller from the map
*/
// map.setUIToDefault();
/*
Now just show show controller on the map exclusively by adding below code
*/
map.removeMapType(G_HYBRID_MAP);
map.removeMapType(G_SATELLITE_MAP);
map.addControl(new GLargeMapControl3D);
var mapControl = new GMapTypeControl(); map.addControl(mapControl);
}
}

Here one thing is notable we have added removeMapType function again to hadle any luck of removing map tabs anyhow.

 

Related posts:

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video... Read More about Chandra Shekhar

Latest posts by Chandra Shekhar (see all)