Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Night mode for Google maps?

My question is simple. Is there a night mode for Google maps? So far I could only apply GoogleMap.MAP_TYPE_NORMAL | GoogleMap.MAP_TYPE_TERRAIN | GoogleMap.MAP_TYPE_SATELLITE but could not find Night Mode. I want something like this enter image description here

Please do not suggest me to use overlay, I already have tried. I cannot use it as I have to place markers on it.

Came across this post but it is 2 years old and I guess there should be some improvement.

like image 302
Shahzeb Avatar asked Aug 28 '16 13:08

Shahzeb


3 Answers

Its easy just create a raw folder and right click raw folder and select new in that new select file and then type file name eg:map_in_night then click ok after it displays different formats don't confuse you just select json and click ok and in that json file just add below code

[
  {
    "featureType": "all",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#242f3e"
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.text.stroke",
    "stylers": [
      {
        "lightness": -80
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#746855"
      }
    ]
  },
  {
    "featureType": "administrative.locality",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#d59563"
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#d59563"
      }
    ]
  },
  {
    "featureType": "poi.park",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#263c3f"
      }
    ]
  },
  {
    "featureType": "poi.park",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#6b9a76"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#2b3544"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#9ca5b3"
      }
    ]
  },
  {
    "featureType": "road.arterial",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#38414e"
      }
    ]
  },
  {
    "featureType": "road.arterial",
    "elementType": "geometry.stroke",
    "stylers": [
      {
        "color": "#212a37"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#746855"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "geometry.stroke",
    "stylers": [
      {
        "color": "#1f2835"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#f3d19c"
      }
    ]
  },
  {
    "featureType": "road.local",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#38414e"
      }
    ]
  },
  {
    "featureType": "road.local",
    "elementType": "geometry.stroke",
    "stylers": [
      {
        "color": "#212a37"
      }
    ]
  },
  {
    "featureType": "transit",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#2f3948"
      }
    ]
  },
  {
    "featureType": "transit.station",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#d59563"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#17263c"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#515c6d"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "labels.text.stroke",
    "stylers": [
      {
        "lightness": -20
      }
    ]
  }
]

in onMapReady just add

mMap = googleMap;  
mMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night));

That's it

like image 154
Manoj Reddy Avatar answered Oct 03 '22 06:10

Manoj Reddy


Google just announced having launched custom map styling for Android and iOS together with a new styling wizard that allows you to design the style once, and apply it across the board on all supported platforms: Android, iOS, JavaScript API, and even Static Maps API.

The Google Maps Android API developer docs even provide a working night mode style example. A code sample using custom styles is also available.

like image 45
Ville N. Avatar answered Oct 03 '22 04:10

Ville N.


Head to :

https://mapstyle.withgoogle.com

Create what you need copy the json save it in a .json file.Put it on res/raw and then use:

mMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.name));

You should call the above function on : onMapReady callback.

like image 24
Steve Moretz Avatar answered Oct 03 '22 05:10

Steve Moretz