How to remove a MapType from google map using Google Maps Javascript V3 API?
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
}
va开发者_高级运维r 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.
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
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.
So there's no URL attribute for disabling the satellite/terrain maps from Google's own embed code?
To disable only map control, use this option in Gmap3 documentation :
mapTypeControl
Type: booleanThe initial enabled/disabled state of the Map type control.
example:
var options = {
// ...
mapTypeControl: false
}
var map = new google.maps.Map(document.getElementById("map"), options);
精彩评论