Flutter styled map

后端 未结 2 446
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 00:58

Is it possible to use json generated from Google Styling Wizard to stylize the Flutter native map?

2条回答
  •  一向
    一向 (楼主)
    2021-01-03 01:30

    Yes. Copy and paste the JSON into the styles variable in your initMap function, like this:

    function initMap() {
        var map = new google.maps.Map(document.getElementById('map'), {
            center: {lat: 40.674, lng: -73.945},
            zoom: 12,
            styles: [
                {elementType: 'geometry', stylers: [{color: '#242f3e'}]},
                {elementType: 'labels.text.stroke', stylers: [{color: '#242f3e'}]},
                {elementType: 'labels.text.fill', stylers: [{color: '#746855'}]},
                {
                    featureType: 'administrative.locality',
                    elementType: 'labels.text.fill',
                    stylers: [{color: '#d59563'}]
                }
            ]
        });
    }
    

    Read this for more info about styling the Google maps.

提交回复
热议问题