Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a MapType from google map using Google Maps Javascript V3 API?

Tags:

Here is the snippet I am using to display Google map on my app using their V3 Javascript API.

var myOptions = {             zoom: 15,             mapTypeId: google.maps.MapTypeId.ROADMAP          } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

But the map shows terrain, hybrid and satellite which I don't want. How do I remove those controls from the map.

like image 467
Anand Avatar asked Dec 01 '10 05:12

Anand


People also ask

How do I remove a marker from Google Maps API?

You can delete the markers by removing them from the map and then setting the array's length to 0 , which removes all references to the markers.


2 Answers

You can remove all the default UI

var mapOptions = {             zoom: 15,             mapTypeId: google.maps.MapTypeId.ROADMAP,             disableDefaultUI: true         };  var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 

And then you can add your own controls

Or you can just add mapTypeControl: false

like image 108
Argiropoulos Stavros Avatar answered Oct 01 '22 06:10

Argiropoulos Stavros


The Google Maps v3 API doc is great.

In it, you'll find that MapOptions have a property, "mapTypeControl", which is a boolean. Set it to false to disable it for your map.

like image 39
August Lilleaas Avatar answered Oct 01 '22 05:10

August Lilleaas