Google Maps - STYLES not working

By Mikey - January 22, 2022

Howdy folks,

I have some code seen below I have used for years. Everything works fine - with the exception of the "var styles" section. The purpose of the "var styles" is to make the maps grayscale by removing the saturation of color from the map. However, this no longer appears to be working and my maps are the default color of Google maps.

I have attached an image showing the color I am trying to achieve. 

Any suggestions on how to get this working again?

Thank Zicky

  <script type="text/javascript"> 
  $(window).load()
        { var styles = [
            {"stylers": [{ "saturation": -100 }]}
        ]; }
    function initialize() { 
      var latitude    = <?php echo floatval(@$maprecord['latitude']); ?>; 
      var longitude   = <?php echo floatval(@$maprecord['longitude']); ?>; 
      var mapCanvasId = 'map_canvas';
      if (latitude) {
        var mapOptions  = { mapTypeId: google.maps.MapTypeId.ROADMAP,
		    scrollwheel: false,
                    mapTypeControl: false,
                    streetViewControl: false,
		    styles: styles
					};
		//var mapOptions  = { mapTypeId: google.maps.MapTypeId.TERRAIN };
		//var mapOptions  = { mapTypeId: google.maps.MapTypeId.HYBRID };
        var map         = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions);
        var latLng      = new google.maps.LatLng(latitude, longitude);
        var marker      = new google.maps.Marker({map: map, position: latLng });

        map.setCenter(latLng);
        map.setZoom(18);
      }
    }
  </script>

By Codee - January 27, 2022

Hi Zicky, Don't know if this helps but a thought or two... According to Google you should still be able to use their "old style wizard" https://mapstyle.withgoogle.com/

Google has started pushing using their cloud-based maps styling wizard https://developers.google.com/maps/documentation/cloud-customization/cloud-based-map-styling

If they are not functioning properly then recommend checking your api is not erroring or if there was a change in parameters/coding that no longer applies (if using that route), consider another methodology.  It doesn't appear you are using Wordpress on this site (some of the widgets are notorious for not working across all browsers), but IF you are using a type of widget or 3rd-party app then maybe ensure that's still a best or viable route.

Good luck!