1

Is it possible to change visibility or opacity of google base map ? I am adding it like in simple example, and adding data layer as overlay and want to see only vector markers. Is it possible?

var map;
function initialize() {
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644)
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);
  • See this answer. Note the question is about CartoDB, but the answer is about google-maps baselayers. – John Powell Feb 1 '15 at 12:22
3

To add transparency to your code you would have to modify your example like this:

var map;
var MY_MAPTYPE_ID = 'custom_style';

function initialize() {

var options = [{
    stylers: [{lightness:90}]
 }];


 var mapOptions = {
      zoom: 8,
      center: new google.maps.LatLng(-34.397, 150.644),
      mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, MY_MAPTYPE_ID]
   },
   mapTypeId: MY_MAPTYPE_ID};

  map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

   var styledMapOptions = {
       name: 'Custom Style'
     };   

   var customMapType = new google.maps.StyledMapType(options, styledMapOptions);  

   map.mapTypes.set(MY_MAPTYPE_ID, customMapType);

   }

   google.maps.event.addDomListener(window, 'load', initialize);

In this case the basemap would take a 90% transparency (referred to in the code as lightness).

The following links can be very useful when styling maps: Styled Maps and an example.

Please let me know if the code makes sense to you, or if you need further explanation.

0

There is also a good source of styles at Snazzy Maps, a community built around creating great looking styles for Google Maps. Your might want to check it out:

https://snazzymaps.com/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.