androidgoogle-mapsandroid-maps-v2

How to change color of Google map in Android


Here I'm trying to changing the color of google map into black from white but not getting a good solution. I tried it to change by using a relative layout over it but it hides that part , it doesn't change color of GoogleMap.

            <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/map"
                class="com.google.android.gms.maps.MapFragment"
                android:layout_width="match_parent"
                android:layout_height="100dp" />

Solution

  • I got a solution of it by running a Html file of Google Map in WebView by putting that html file into assets folder. And I used following code to display

    <!DOCTYPE html>
    <html>
    <head>
    <title>Panoramio Layer</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
        html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
        }
        #panel {
        position: absolute;
        top: 5px;
        left: 50%;
        margin-left: -180px;
        z-index: 5;
        background-color: #fff;
        padding: 5px;
        border: 1px solid #999;
        }
        #photo-panel {
        background: #fff;
        padding: 5px;
        overflow-y: auto;
        overflow-x: hidden;
        width: 300px;
        max-height: 300px;
        font-size: 14px;
        font-family: Arial;
        border: 1px solid #ccc;
        box-shadow: -2px 2px 2px rgba(33, 33, 33, 0.4);
        display: none;
        }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=panoramio"></script>
    <script>
    function initializeGmaps() {
    var LatLng = {lat: 28.596979, lng: 77.326742};
    var mapCanvas = document.getElementById('google-map');
    var mapOptions = {
    center : LatLng,
    scrollwheel : false,
    zoom : 14,
    mapTypeId : google.maps.MapTypeId.ROADMAP,
    backgroundColor: 'none',
    styles : [{
    stylers: [
    { invert_lightness: true },
    { hue: '#666' },
    { saturation: -100 },
    { lightness: -0 },
    { visibility: 'simplified' }
    ]
    }]
    }
    var map = new google.maps.Map(mapCanvas, mapOptions);
    var marker = new google.maps.Marker({
    position: LatLng,
    map: map,
    icon: '<?=base_url();?>images/marker.png',
    title: 'Advisorymandi.com Pvt. Ltd.'
    });
    }
    google.maps.event.addDomListener(window, 'load', initializeGmaps);
    
    </script>
    </head>
    <body>
    <ul id="photo-panel">
    <li><strong>Photos clicked</strong></li>
    </ul>
    <div id="google-map" class="youplay-gmaps" style=" height: 450px; width: 100%;"></div>
    </body>
    </html>