Flutter styled map

后端 未结 2 432
隐瞒了意图╮
隐瞒了意图╮ 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:11

    There is no such ability in current version. But soon it can be achieved due to this pull request


    Update

    Finally it has been merged with #1697 pull request! And it's published in 0.5.16 version of google_maps_flutter.

    How to

    To use this feature invoke setMapStyle on GoogleMapController instance and pass style string as a parameter.

    e.g.

    GoogleMapController mapController;
    void _onMapCreated(GoogleMapController controller) {
        mapController = controller;
        mapController.setMapStyle('[{"featureType": "all","stylers": [{ "color": "#C0C0C0" }]},{"featureType": "road.arterial","elementType": "geometry","stylers": [{ "color": "#CCFFFF" }]},{"featureType": "landscape","elementType": "labels","stylers": [{ "visibility": "off" }]}]');
      }
    

    From the docs:

    Sets the styling of the base map.

    Set to null to clear any previous custom styling.

    If problems were detected with the [mapStyle], including un-parsable styling JSON, unrecognized feature type, unrecognized element type, or invalid styler keys: [MapStyleException] is thrown and the current style is left unchanged.

    The style string can be generated using map style tool. Also, refer iOS and Android style reference for more information regarding the supported styles.

提交回复
热议问题