vicmora / MMM-GoogleMapsTraffic

A raspberry pi MagicMirror module that displays a map, centered at provided coordinates, with Google Maps Traffic information.
MIT License
88 stars 32 forks source link

Google Maps API does not support custom mapStyle anymore #46

Open JakeBinney opened 1 year ago

JakeBinney commented 1 year ago

Google Maps API has transitioned to using a user-defined mapId per current documentation

Recommend deprecating the existing mapStyle config and replacing with mapId.

mapId is a 16-character hex identifier to a user-defined map style on the Maps Platform

Example API call replacing mapStyle with mapId in MMM-GoogleMapsTraffic.js:

           var map = new google.maps.Map(document.getElementById("map"), {
                zoom: self.config.zoom,
                mapId: self.config.mapId,
                center: {
                    lat: self.config.lat,
                    lng: self.config.lng
                },
                disableDefaultUI: self.config.disableDefaultUI,
                backgroundColor: self.config.backgroundColor
            });

This requires a minor update to defaults object to include mapId, and an update to config.js call to utilize mapId